Javascript - Write program to use the continue statement to skip the third value in array.

Requirements

Use the continue statement to not output the array's element "Java".


var nameList = ["Json", "XML", "Java", "Ford"];
var text = ""
var i;
for (i = 0; i < nameList.length; i++) {
    //your code here
    text += nameList[i] + "\n";
}
console.log( text );

Hint

Insert an if statement which checks if nameList[i] === "Java", then add continue;

Demo

var nameList = ["Json", "XML", "Java", "Ford"];
var text = ""
var i;/*from w  w w  .j av a 2 s  .  c  om*/
for (i = 0; i < nameList.length; i++) {
    if (nameList[i] === "Java") 
       continue;
    text += nameList[i] + "\n";
}
console.log( text );

Result

Related Exercise