How do I read information from a JSON file into a JavaScript so that I can display that value into a HTML page?
In the if statement and the item.innerHTML line are both not picking up the data from the JSON file.
I have the animal's value reading in from the JSON file and then the if statement prints the information a HTML file
let animals = JSON.parse(animals);
for(let i = 0; i < animals.length; i++){
if(animals.dogs[i].dogId === dog[i]) {
item.innerHTML += "<li>" + animals.dogs[i].dogName + "</li>";
}
}
The data in the JSON file looks like this:
{
"animals": {
"dogs": [
{
"dogId": "DW-001",
"dogName": "Fido",
"dogType": "Poodle",
"dogType": "Small",
"description": "Excellant lap dog, doesn't shed.",
"pricePerHour": "3.0"
}
]
}
}