Skip to content

Instantly share code, notes, and snippets.

@ldco2016
Created March 24, 2018 17:50
Show Gist options
  • Save ldco2016/54289bf684e1d57b627ad695f07f1331 to your computer and use it in GitHub Desktop.
Save ldco2016/54289bf684e1d57b627ad695f07f1331 to your computer and use it in GitHub Desktop.
example of my version of the beginning stages of the JavaScript for a quiz app
var output = document.getElementById('output');
var myData = '[{"question":"What color is an apple?","answers":["Blue","Red","Purple"],"correct":1},{"question":"What color is grass?","answers":["Green","Red","Purple"],"correct":0}]'
var myObj = JSON.parse(myData);
for (var i in myObj) {
output.innerHTML += myObj[i].question + '? <br>';
}
output.innerHTML = myObj[0].question;
console.log(myObj);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment