I'm attempting to have when the function is called that values in the array are displayed using while loops. It will display the first object except for the picture and not the other two
function products(){
var txt=""
var appliance = 0
var products = new Array();
products[0] = {name: "refrigerator" , price:88.99,
img:"img/refrigerator.jpg"};
products[1] = {name: "microwave oven" , price: 76.99 , img:"img/microwave.png"};
products[2] = {name: "dishwasher" , price:276.67 , img:"img/dishwasher.jpg"};
/*var appliance = products[x].name + " " + products[x].price + " '" + products[x].img + "'>"*/
while(appliance < 3){
txt +=products[appliance].name + ' ' + products[appliance].price +" <img src='"+ products[appliance].img;"'>";
appliance++;
}
document.getElementById("answer").innerHTML = txt
}
}
productsobject or the entire thing printed out?forform is often more idiomatic). Please write a title - and use tags - that apply to the problem.