The question is : Convert your object to a JSON string myString and display it in a somewhere on the page. Here is my code:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title> JSON </title>
<script>
var fidoString = '{ "name": "Fido", "breed": "Mixed", "weight": 38 }';
var fido = JSON.parse(fidoString);
console.log("We have made a dog out of a string! " + fido.name);
var fido2 = {
name: "Fido",
breed: "Mixed",
weight: 38
};
var fido3 = {
name: {
first: "alex",
second: "doggy"
},
breed: "Mixed",
weight : 30
};
var fidoString = JSON.stringify(fido2);
console.log("We made a string from a dog! " + fidoString);
var x = fido3.name
document.getElementById("lista").innerHTML = x;
</script>
</head>
<body>
<div id="lista"></div>
</body>
</html>
I got error: JSON.html:31 Uncaught TypeError: Cannot set property 'innerHTML' of null at JSON.html:31. Can't fix this error and need some help.