How to print for loop numbers with console in one line with JavaScript

1 Answer

0 votes
let s = "";
for(let i = 1; i <= 10; i++) {
  s += i + " ";
}

console.log(s);



/*
run:

1 2 3 4 5 6 7 8 9 10 

*/

 



answered Jul 1, 2020 by avibootz
...