-
-
Save nolds9/efdb0a320e7143f42e96 to your computer and use it in GitHub Desktop.
Model WDI Student Object
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 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