Conditionals and loops
Conditional statements
// Example: generate a random temperature between -100 and 200 degrees Celsius.
// Then, return the state of water in that temperature.
let degreesCelsius = random(-100, 200);
if degreesCelsius <= 0 {
return "ice";
}
else if degreesCelsius > 100 {
return "water vapour";
}
else {
return "liquid water";
}Loops
for loops
while loops
break
continue
Last updated
Was this helpful?