Run a part of the program in the background and keep running it over again.

forever(() => {

The code you have in a ||loops:forever|| loop will run and keep repeating itself the whole time your program is active. Code in other parts of your program won’t stop while your ||loops:forever|| loop is running. This includes other ||loops:forever|| loops and the ||control:run in parallel|| block.


  • a: the code to keep running over and over again.


Create an mood generator that writes a current mood to the console every 5 seconds.

let mood = ["happy", "sad", "joyful", "angry"]
forever(function () {
    console.log("mood = " + mood[Math.randomRange(0, 3)])

See also

while, repeat, run in parallel