1

I am trying to get multiple input and process them in the for loop. For Example -

for(let i = 0; i < 10; i++) {
    input = how to get this is my question 
    if(input % 2 == 0) {
        console.log('YES');
    } else if(input % 2 == 1) {
        console.log('NO');
    }
}

So this is the method I wanna take the input and process it I wanna use node.js methods and without "await" as it causes some issue in non-high level Module.

  • 1
    Does this answer your question? [Get user input through Node.js console](https://stackoverflow.com/questions/61394928/get-user-input-through-node-js-console) – Mushroomator May 06 '22 at 12:13
  • To resolve the high-level module issue you could use `(async () => { // your code here})();`. – Mushroomator May 06 '22 at 12:14
  • @Mushroomator I did see those earlier and they didn't specify for loops,Would encourage to upvote to bring this question upfront – ScienceGuy66 May 07 '22 at 13:10
  • The `for` loop doesn't change anything really. You'll just be doing the same thing as in the linked question except that you will be doing it more than once. You will need to `await` the result or get the callback function to work (which is a little tricky in a for loop), so I would recommend you look at the `await` option mentioned is this [answer](https://stackoverflow.com/a/68504470/17487348) as it will be the easiest solution. – Mushroomator May 07 '22 at 13:13
  • @Mushroomator So I did see that example tried to implement it in for loop but no luck also to give some context I wanna use this for coding problems websites so im having hard time doign that without some other externsiom which is tricky – ScienceGuy66 May 09 '22 at 13:33
  • Can you please update the question with what you have tried, which exact error you get and what you would expect instead? – Mushroomator May 09 '22 at 15:06

0 Answers0