sigle line result of console.log | Sololearn: Learn to code for FREE!

0

sigle line result of console.log

get result one line in console.log of javascript how to get the output like this. not make the new line. for (var i = 0; i < 9; i++) { console.log(i);} 0 1 2 3 4 5 6 7 8 //dream_output:012345678

12/6/2020 9:56:07 PM

Yusuf Abdulloh

2 Answers

New Answer

+4

let output = ""; for (let i = 0; i < 9; i++) { output += i; } console.log(output); Or console.log([...Array(9).keys()].join(''));

+2

Yusuf Abdulloh you have to create a line as my example shows: let n = 15; for (i = 1; i <= n; i++){ var line = ""; for (j = 1; j <= n; j++){ line+=" "+j; } } console.log(line);