sigle line result of console.log | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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

6th Dec 2020, 9:56 PM
Yusuf Abdulloh
Yusuf Abdulloh - avatar
2 Answers
+ 4
let output = ""; for (let i = 0; i < 9; i++) { output += i; } console.log(output); Or console.log([...Array(9).keys()].join(''));
6th Dec 2020, 10:13 PM
ChaoticDawg
ChaoticDawg - avatar
+ 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);
6th Dec 2020, 10:22 PM
BroFar
BroFar - avatar