<!DOCTYPE html>
<html lang="en-US">
<body>
<h1>JSON Adding Keys to the object</h1>
<button onclick="myFunction()">Click Me</button>
<script>
var data = [
{
"name": "Mike",
"age": 36
}
]
function myFunction(){
// Adding a key (married) to the first object by using dot notation.
data[0].married = true;
// Adding a key (partner) to the first object by using bracket notation.
data[0]["partner"] = "Jade";
console.log(data);
}
</script>
<p><strong>Note</strong>: Click on the button and check your console.</p> </body>
</html>