Skip to content

Instantly share code, notes, and snippets.

@pads
Created July 11, 2020 13:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pads/dea104f1e901fdf4188ce4c73f732850 to your computer and use it in GitHub Desktop.
Save pads/dea104f1e901fdf4188ce4c73f732850 to your computer and use it in GitHub Desktop.
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