Created
September 7, 2017 20:47
-
-
Save JacobTheEvans/a6ac94bc38f5b0fc848c5d920447651f to your computer and use it in GitHub Desktop.
Using base JavaScript to add array of data to page
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 menu = [ | |
{ | |
name: "Pizza", | |
cost: 10, | |
isGood: true | |
}, | |
{ | |
name: "Sandwich", | |
cost: 10, | |
isGood: true | |
} | |
]; | |
var menuElem = document.getElementById("menu"); | |
for(var i = 0; i < menu.length; i++) { | |
var listElem = document.createElement("li"); | |
var listText = document.createTextNode("name: " + menu[i].name + " cost: " + menu[i].cost); | |
listElem.appendChild(listText); | |
menuElem.appendChild(listElem); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment