I have a question that is it possible to print the output in the same line by using console.log in JavaScript? I know console.log always a new line. For example:
"0,1,2,3,4,5,"
Thanks in advance!
I have a question that is it possible to print the output in the same line by using console.log in JavaScript? I know console.log always a new line. For example:
"0,1,2,3,4,5,"
Thanks in advance!
in nodejs there is a way:
process.stdout
so, this may work:
process.stdout.write(`${index},`);
where:
index
is a current data and,
is a delimiteralso you can check same topic here
You can print them as an array
if you write:
you can get
Couldn't you just put them in the same call, or use a loop?
You can just
console.log
the strings all in the same line, as so:And to create a new line, use
\n
:If you are running your app on node.js, you can use an ansi escape code to clear the line
\u001b[2K\u001b[0E
:You could just use the spread operator
...