JSON Examples

6- JSON Notation

Output

JS

var People = [
    {
        "firstName":  "Joe",
        "midName":    "Alan",
        "lastName":   "Dokes",
        "age":        "35"
    },
    {
        "firstName":  "Sally",
        "midName":    "Mae",
        "lastName":   "Linkhouse",
        "age":        "24"
    },
    {
        "firstName":  "Bobby",
        "midName":    "Jessie",
        "lastName":   "Sturmgard",
        "age":        "48"
    }
]

HTML

<script>
    let peeps = '';
                
    for(var i = 0; i < People.length; i++) {
        peeps += People[i].firstName + ' '  + 
                 People[i].lastName + '<br>';
    }
    document.getElementById('info').innerHTML = peeps;
</script>