Odds Then Evens Whiteboard Problem
Write ONE for loop that console.log
's all the even numbers 1 - 10 followed by all the odd numbers 1 - 10.
The result will be:
1
3
5
7
9
2
4
6
8
10
This would be incorrect because a 2nd for loop is used:
for (var i=0;i<whatever.length;i++){
stuff for odd;
}
for (var j=0;j<whatever.length;j++){
stuff for even;
}