Is it possible to print the output in the same line by using console.log()
in JavaScript? I know console.log()
always returns a new line. For example, have the output of multiple consecutive console.log()
calls be:
"0,1,2,3,4,5,"
To create a multi line strings when printing to the JavaScript console, you need to add the new line character represented by the \n symbol. Alternatively, you can also add a new line break using Enter when you use the template literals syntax.
Answer: Use console. log() or JSON. stringify() Method This method will print the object in browser console.
while x < y: ... print '{0} / {1}, '.
stdout. write() method to print to console without trailing newline. Note: The process object is global so it can be used without using require() method.
In Node.js there is a way: process.stdout
So, this may work:
process.stdout.write(`${index},`);
where index
is a current data and ,
is a delimiter.
Also you can check same topic here.
You could just use the spread operator ...
var array = ['a', 'b', 'c'];
console.log(...array);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With