Ask coding questions

← Back to all posts
How do I do a Loop for NODE.JS
RetroBotMaker (0)

What is the code for a loop I have some code that I want to run every second also I would like it to work with fuctions

Comments
hotnewtop
InvisibleOne (2678)

Like this:

for (var i=0; i<10; i++) {
  console.log("This will be printed ten times!");
}

Or if you want to do something once per second

var timer = setInterval(function() {
  console.log("This will be printed every second");
}, 1000) // interval time set here in miliseconds
InvisibleOne (2678)

A setInterval will run until you clear it. @RetroBotMaker