···11+// for loop
22+function testFor() {
33+ let x = 0
44+ for (let i = 0; i < 3; i++) x += 1
55+ return x
66+}
77+88+// while loop
99+function testWhile() {
1010+ let x = 0
1111+ let i = 0
1212+ while (i < 3) i++, x += 1
1313+ return x
1414+}
1515+1616+// if statement
1717+function testIf() {
1818+ let x = 10
1919+ if (x > 5) x = 42
2020+ return x
2121+}
2222+2323+// if-else
2424+function testIfElse() {
2525+ let x = 3
2626+ if (x > 5) x = 100
2727+ else x = 200
2828+ return x
2929+}
3030+3131+// nested
3232+function testNested() {
3333+ let sum = 0
3434+ for (let i = 0; i < 2; i++) for (let j = 0; j < 2; j++) sum += 1
3535+ return sum
3636+}
3737+3838+console.log("for:", testFor()) // 3
3939+console.log("while:", testWhile()) // 3
4040+console.log("if:", testIf()) // 42
4141+console.log("if-else:", testIfElse()) // 200
4242+console.log("nested:", testNested()) // 4