Loops and switch statement
While and for loop
They are the same as in Python, C, and Java
while (condition) {
// Repeat certain code
}
for (begin; condition; step) {
// Repeat certain code
}
break and continue
both works the same way as in any other language.
Switch statement
switch(x) {
case 'value1':
// Do something if x is === 'value1'
break;
case 'value2':
// Do something if x is === 'value2'
break;
default:
// Do something if x isn't equal to any value above
break;
}
The equality for the case is checked using strict equality (===).
No Comments