Skip to content

Instantly share code, notes, and snippets.

@nolds9
Last active February 12, 2016 21:08
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 nolds9/efdb0a320e7143f42e96 to your computer and use it in GitHub Desktop.
Save nolds9/efdb0a320e7143f42e96 to your computer and use it in GitHub Desktop.
Model WDI Student Object
var wdiStudent = {
name: "Charlie Kelly",
squad: "Paddys",
classesTaken: ["git intro", "cli", "css" ],
"number-of-tardies": 0,
favoriteFood: "Milksteak",
enrolled: true,
hobby: "Magnet"
}
// Update two existing properties
wdiStudent["number-of-tardies"]++
wdiStudent.classesTaken.push("js-basics")
// Add a new property
wdiStudent.roommate = "Frank"
// Delete one attribute
delete wdiStudent.hobby
// Iterate through and log key-value pairs
for (attr in wdiStudent){
console.log("The key " + attr + " has the value " + wdiStudent[attr])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment