<!DOCTYPE html>
<html lang="en-US">
<body>
<h1>JSON Syntax</h1>
<p id="point"></p>
<button onclick="firstFriend()">First Friend</button>
<button onclick="allFriends()">All Friends</button>
<script>
var data = [
{
"name": "Mike",
"age": 36,
"friends": ["John", "Antony"]
},
{
"name": "Alex",
"age": 30,
"friends": ["Jade", "Jasmine"]
}
]
function firstFriend(){
document.getElementById("point").innerHTML = data[1].friends[0];
}
function allFriends(){
document.getElementById("point").innerHTML = data[1].friends;
}
</script>
<p><strong>Note</strong>: Click on the button to get the friend(s) of Alex.</p> </body>
</html>