-3

I want to add a space after console.log in JavaScript, not new line. Like in Python:

for i in range(5):
    print(i, end=' ')
2
  • what happen when you use console.log(i+' '); Commented May 13, 2019 at 19:21
  • No I didn't check that. Will it print as same? Commented May 13, 2019 at 19:22

1 Answer 1

-4
console.log(i + ' ')

This will print a string i and a space after.

Sign up to request clarification or add additional context in comments.

7 Comments

...and then a newline. end=' ' in Python 3.x suppresses the line feed.
print does not log to the console in JavaScript.
maybe I am misunderstanding the question. It looks to me like OP wants to console.log a string followed by a single space.
But crucially "not new line"
Ok I got it now. The desired thing is process.stdout.write(i + " "). Thanks all.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.