Last active
November 1, 2017 18:18
-
-
Save Sstobo/96428842bb297b8af4feba4b4aa9dd7f to your computer and use it in GitHub Desktop.
[JS for JSON] # json
This file contains hidden or 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 person = { | |
name: "Brad", | |
age: 35, | |
kids: ["dave", "nick"], | |
address: { | |
street: "Mansfield", | |
city: "ottawa" | |
} | |
} | |
var people = [ | |
{ | |
name: "Brad", | |
age: 15 | |
}, | |
{ | |
name: "jon", | |
age: 40 | |
}, | |
{ | |
name: "sar", | |
age: 25 | |
} | |
]; | |
console.log(person.address.street); | |
console.log(person.kids[1]); | |
console.log(people[1]); | |
// Iterate through and list names | |
var output= ""; | |
for(var i = 0; i < people.length; i++){ | |
console.log(people[i]); | |
output += "<li>" + people[i].name + "</li>" | |
} | |
document.getElementById("people").innerHTML = output; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment