User Interface Expert Question:
Download Questions PDF

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?

UI Developer Interview Question
UI Developer Interview Question

Answer:

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]);
}
}
}

Download UI Developer Interview Questions And Answers PDF

Previous QuestionNext Question
Tell me what is the difference between HTML5 interaction in Sencha and Twitter/Bootstrap?Explain the difference between cookies, sessionStorage, and localStorage?