I have been studying JS for a week only. I don't know what I'm missing:
Define a function checkProperty() that will use the following object passed as an argument to print the output in the console.
The output: if the property isForSale equals to true, the expected output to the console should be: The owner, John Doe put the home for sale! The property has 4 amenities.. In the other case, we should see the following: The home in Happy St no. 123 is not for sale.
I only get the second sentence printed out. Why?
owner: {
firstName: 'John',
lastName: 'Doe',
age: 44
},
isForSale: true,
sqrm: 120,
address: {
street: 'Happy St',
number: 123,
city: 'Miami',
state: 'FL',
country: 'US'
},
amenities: ['pool', 'tennis court', 'private parking', 'yard']
};
function checkProperty(someObject){
if(someObject.isForsale === true){
console.log(`The owner, ` + property.owner.firstName + ` ` + property.owner.lastName + ` put the home for sale! The property has` + property.amenities.lenght + ` amenities.`)}else{
console.log(`The home in ` + property.address.street + ` no. ` + property.address.number + ` is not for sale.`)
}
}
checkProperty(property);```
Output: "The home in Happy St no. 123 is not for sale."
Aucun commentaire:
Enregistrer un commentaire