Every time you use the keyword continue you are skipping the rest of the code below it and jumping back to the top of your while loop. This means that i++ is never reached once you continue, and so, you will always be looking at the integer 1990 in your array. Thus continue will always be called as your if statement will be stuck looking like so:
if(typeof 1990 !=== 'string') {
// true so code will fire
continue; // you reach continue so your loop runs again, running the same if statement check as you haven't increased 'i' (so it checks the same element)
}
// all code below here will not be run (as 'continue' is used above)
Instead, you need to increment in your if statement and outside of it. Allowing you to look at the next value in your array:
var john = ['john', 'smith', 1990, 'designer', false, 'blue' ];
var i = 0;
while ( i < john.length) {
if( typeof john[i] !== 'string') {
i++; // go to next index
continue;
}
console.log( john[i]);
i++;
}
continueskips the rest of the loop, including thei++, so onceiis2the loops runs forever.ireaches2,typeof john[i]is"number", so JS callscontinue. The loop continues, butiis still2. Just use this instead: jsfiddle.net/khrismuc/jn8pwzmc