Created
July 11, 2020 13:13
-
-
Save pads/dea104f1e901fdf4188ce4c73f732850 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://github.com/CodeYourFuture/JavaScript-Core-2-Homework/blob/master/Week-1/InClass/C-more-complex-objects/exercise-2.js | |
/* | |
Given the same "house" object again | |
Follow the instructions below and then run the file and make sure it outputs the correct results | |
*/ | |
let house = { | |
address: "1 Kinning Park", | |
previousOwners: ["Claire M.", "John A."], | |
currentOwner: { | |
firstName: "Margaret", | |
lastName: "Conway", | |
}, | |
}; | |
let newCurrentOwner = { | |
firstName: "Georgina", | |
lastName: "Hernandez", | |
}; | |
// /* | |
// DO NOT EDIT ANYTHING ABOVE THIS LINE | |
// WRITE YOUR CODE BELOW | |
// */ | |
house.currentOwner = newCurrentOwner; | |
house.previousOwners[1] = "Stephen B."; | |
house.isForSale = false; | |
// - assign the value of the variable 'newCurrentOwner' as the value to the house's "currentOwner" | |
// - from the list of previous owners, replace only "John A." with "Stephen B." | |
// - give the house a new property called 'isForSale' with the value 'false' | |
// /* | |
// DO NOT EDIT ANYTHING BELOW THIS LINE | |
// */ | |
console.log( | |
`Did you correctly assign the new owner using the given variable?","Expected result: true. Actual result: " ${ | |
house.currentOwner === newCurrentOwner | |
}` | |
); | |
console.log( | |
`Expected result: Claire M., Stephen B. Actual result: ${house.previousOwners.toString()}` | |
); | |
console.log(`Expected result: false. Actual result: ${house.isForSale}`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment