I want to print a list (var lst=[1,2,3,4,5]) using a loop on the same line. Can I do that in JavaScript ?
Well you can achieve this by doing this. Make an empty string variable and then concatenate each array value to it, then print it out. This will work
var lst = [1, 2, 3, 4, 5];
var output = "";
for (var i = 0; i <= lst.length; i++){
output += lst[i] + " ";
}
console.log(output);
In NodeJS and as long as you didn't change your standard output you can use process.stdout.write("Something here")
as the standard output of your application is terminal (console).
process.stdout.write("Hello ")
process.stdout.write("World")
process.stdout.write("!")
Hello world!
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