I try to using continue in for loop to skip every 5th iteration. But, I just know how to write the continue in which just skip the first 5th. Not sure how I can implement the continue statement to make it work. The correct output should be:
1 is odd.
2 is even.
3 is odd.
4 is even.
6 is even.
7 is odd.
8 is even.
9 is odd.
11 is odd.
12 is even.
13 is odd.
14 is even.
16 is even.
17 is odd.
18 is even.
19 is odd.
Here is my code.
forwardOp(1,20)
function forwardOp(startIndex, endIndex){
if (startIndex > endIndex){
console.log("Start number cannot be less than End number.");
}
for (i = startIndex; i <= endIndex; i++){
if (i === 5){continue;}
if (i % 2 ==0){
console.log (i," is even.")
}else {
console.log (i, " is odd.")
}
}
}