var txt=" ";
var basket= {
item1:"rice",
item2:"salt",
item3:"banana",
item4:"cake",
item5:"apple",
item6:"grape",
item7:"meat",
item8:"mango",
dress:{
shirt:{
1:"t-Blue",
2:"t-black",
3:"t-green",
4:"t-red",
6:"t-yellow",
7:"t-Orange",
},
pants:{
a:"p-Blue",
b:"p-black",
c:"p-green",
d:"p-red",
e:"p-yellow",
f:"t-Orange",
},
silk:{
a:"p-Blue",
b:"p-black",
c:"p-green",
d:"p-red",
e:"p-yellow",
f:"t-Orange",
}
}
}
for (x in basket)
{
txt+= basket[x]+","+" ";
}
document.getElementById("p3").innerHTML= txt;
What I have tried:
I tried to print valus from an array in javascript. but its not working. can anyone can please tell me what is the problem.