console
let out1='';
const console= {};
console.log= (msg)=>{
out1+= msg + '<br>';
}
class Car{
constructor(model='', color='', age=0){
this.model= model;
this.color= color;
this.age= age;
}
set condition(condition={}){
try{
if(condition){
for (const prop in condition) {
if (!this.hasOwnProperty(prop)) throw new TypeError('property type error');
this[prop]= condition[prop];
}
}
} catch(e){
console.log(e.message);
}
}
get condition(){
return `${this.model} - ${this.color} - ${this.age} years old`;
}
}
let ford= new Car('Mustang','blue',5);
console.log(ford.condition);
ford.condition={age:10};
console.log(ford.condition);
ford.condition={modell:'fusion', age:10};
console.log(ford.condition);
document.querySelector('#output').innerHTML = out1;
<div class='container'>
<div id='output'>
<h1 style='color: white;'> Switch to Dark Theme to see the result</h1>
<h1 style='color: Black;'> Switch to Dark Theme to see the result</h1>
</div>
</div>
body{
background: #FCFCFC;
}