This site is mobile accessible. Press the "Tap Here" button to use a different font-size.


Smartphone icons created by Freepik - Flaticon

Looping an Array

// create myJSON
const myJSON = '{"name":"John", "age":30, "cars":["Ford", "BMW", "Fiat"]}';

// create myObj from myJSON
const myObj = JSON.parse(myJSON);

// loop through the array values
let text = "";
for (let i in myObj.cars) {
  text += myObj.cars[i] + ", ";
}

// display the values of the array
document.getElementById("demo").innerHTML = text;