Skip to content

Instantly share code, notes, and snippets.

@Sstobo
Last active November 1, 2017 18:18
Show Gist options
  • Save Sstobo/96428842bb297b8af4feba4b4aa9dd7f to your computer and use it in GitHub Desktop.
Save Sstobo/96428842bb297b8af4feba4b4aa9dd7f to your computer and use it in GitHub Desktop.
[JS for JSON] # json
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