I need to figure out how to output a list of numbers in a loop to the console. However, the output to the console must be in the same line, as opposed cascading down the page with every new number. Below, I have two separate blocks of code that accomplish the same thing. One uses a while loop and the other uses a for loop. If there's a difference between being able to accomplish this in a for loop versus a while loop, I'd like to know that as well. Thank you.
While Loop
var number = 2;
while (number <=10) {
console.log(number++);
number = number + 1;
}
For Loop
for (var number = 2; number <= 10; number = number + 2)
console.log(number);