Created
January 20, 2014 05:54
-
-
Save brittanmcg/8515583 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
var terah = { | |
name: "Terah", | |
age: 32, | |
height: 66, | |
weight: 130, | |
hairColor: "brown", | |
eyeColor: "brown" | |
} | |
// __________________________________________ | |
// Write your code below. | |
var adam = { | |
name: "Adam", | |
spouse: terah, | |
children: { | |
name: "Carson" | |
} | |
}; | |
terah["spouse"] = adam; | |
terah["weight"] = 125; | |
delete terah["eyeColor"]; | |
terah.children = {name: "Carson"}; | |
// adam.spouse.children; | |
// __________________________________________ | |
// Driver Code: Do not alter code below this line. | |
function assert(test, message, test_number) { | |
if (!test) { | |
console.log(test_number + "false"); | |
throw "ERROR: " + message; | |
} | |
console.log(test_number + "true"); | |
return true; | |
} | |
assert( | |
(adam instanceof Object), | |
"The value of adam should be an Object.", | |
"1. " | |
) | |
assert( | |
(adam.name === "Adam"), | |
"The value of the adam name property should be 'Adam'.", | |
"2. " | |
) | |
assert( | |
terah.spouse === adam, | |
"terah should have a spouse property with the value of the variable adam.", | |
"3. " | |
) | |
assert( | |
terah.weight === 125, | |
"The terah weight property should be 125.", | |
"4. " | |
) | |
assert( | |
terah.eyeColor === undefined, | |
"The terah eyeColor property should be removed.", | |
"5. " | |
) | |
assert( | |
terah.spouse.spouse === terah, | |
"The terah spouse property's value spouse property should be terah.", | |
"6. " | |
) | |
assert( | |
(terah.children instanceof Object), | |
"The value of the terah children property should be an Object.", | |
"7. " | |
) | |
assert( | |
terah.children.carson.name === "Carson", | |
"The terah children property should have a carson property with its own property name with a value of 'Carson'.", | |
"8. " | |
) | |
assert( | |
terah.children.carter.name === "Carter", | |
"The terah children property should have a carter property with its own property name with a value of 'Carter'.", | |
"9. " | |
) | |
assert( | |
terah.children.colton.name === "Colton", | |
"The terah children property should have a colton property with its own property name with a value of 'Colton'.", | |
"10. " | |
) | |
assert( | |
adam.children === terah.children, | |
"The value of the adam children property should be the value of the terah children property", | |
"11. " | |
) | |
console.log("\nHere is your final terah object:") | |
console.log(terah) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment