I have this for loop. It's console logging colors from the color fields in my json file. But there are duplicate colors.
This is my json code
var movies = [
{
"name": "Feugo",
"outline": "Description about Hydrangea flowers.",
"months": [
"Jan",
"Feb",
"Mar",
"Apr",
"Nov",
"Dec"
],
"color": [
"Orange",
"Yellow"
],
"type": [
"Alstroemeria"
],
"image": "alstroemeria-fuego_w300_h400.jpg",
"id": 1
},
{
"name": "Atlanta",
"outline": "Description about Hydrangea flowers.",
"months": [
"Jan",
"Feb",
"Mar",
"Apr",
"Nov",
"Dec"
],
"color": [
"Purple",
"Yellow",
"White"
],
"type": [
"Alstroemeria"
],
"image": "alstroemeria-atlanta_w300_h400.jpg",
"id": 2
},
This is my for loop:
for (var i = 0; i < movies.length; i++) {
var obj = movies[i];
for (var j = 0; j < obj.color.length; j++) {
console.log(obj.color[j]);
}
}
How do I only display one of each?
Thanks!