Answers

Question and Answer:

  Home  UI Developer

⟩ Loop through the "me" object and print each value to the console without assuming you know the keys. Extra bonus print each color in a separate console.log() without assuming you know the key of "fcolors" (detect the array, and handle printing the values of the array?

var me = {"fname": "Global", "lname": "Guideline", "fcolors": ["blue", "green", "whitesmoke"]};

for (var key in me){

if(me.hasOwnProperty(key)){

if(me[key] instanceof Array){

for( var i =0; i < me[key].length; i++ ){

console.log(me[key][i]);

}

} else {

console.log(me[key]);

}

}

}

 163 views

More Questions for you: