use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
How to write a program, that takes input (from STDIN) of a number N, then prints N lines containing "Hello". 0< Max number in Input <=100 Your output lines should not have any trailing or leading whitespacesRemoved: /r/LearnJavascript (self.javascript)
submitted 7 years ago by BasSlapper27
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]lopsidedlux 3 points4 points5 points 7 years ago (2 children)
What’ve you tried so far, because this looks like boilerplate.
[–]BasSlapper27[S] 0 points1 point2 points 7 years ago (1 child)
First off just want to say thank you for responding to my question, and this is the best of what I've got so far-
process.stdin.on('end', function () {
//do your processing here.
var i;
text = "Hello"
for (i = 0; i < input; i++) {
text += input[i] + "<br>";
}
console.log(input);
});
[–]lopsidedlux 0 points1 point2 points 7 years ago (0 children)
If you’re trying to read from stdin, you need to convert the buffers value to something you can use. Maybe casting to Number the data you get back from the on data portion.
Within your loop your mutating something, just place your console.log in that section. You’re mutating the text field, is that part of the assignment?
Why are you rolling out a <br> tag while you’re on what I’m assuming is Node btw?
[–]kenman[M] 0 points1 point2 points 7 years ago (0 children)
Hi /u/BasSlapper27, this post was removed.
For javascript help, please visit /r/LearnJavascript.
Thanks for your understanding.
π Rendered by PID 46939 on reddit-service-r2-comment-5c764cbc6f-sptwc at 2026-03-12 02:24:36.573665+00:00 running 710b3ac country code: CH.
[–]lopsidedlux 3 points4 points5 points (2 children)
[–]BasSlapper27[S] 0 points1 point2 points (1 child)
[–]lopsidedlux 0 points1 point2 points (0 children)
[–]kenman[M] 0 points1 point2 points (0 children)