Title here
Summary here
There are two types of loops in Solar: for
and while
loops.
for
loops are structured to have an initialization statement, an exit condition, and an expression in that order. All of which are optional.
while
loops are structured to have only an exit condition. The exit condition is required, unlike for
loops.
let x = 0;
for (let i = 0; i < 10; i++)
{
x += 1;
}
x; // Returns 10.
while (x < 30)
{
x += 1;
}
x; // Returns 30.