Find more freelance jobs
|
{ case label1: code to be executed if expression = label1 break case label2: code to be executed if expression = label2 break default: code to be executed if expression is different from both label1 and label2 } Looping Very often when you write code, you want allow the same block of code to run a number of times. You can use looping statements in your code to do this. In JavaScript we have the following looping statements: · while - loops through a block of code while a condition is true · do...while - loops through a block of code once, and then it repeats the loop while a condition is true · for - run statements a specified number of times while The while statement will execute a block of code while a condition is true.. while (condition) { code to be executed } do...while The do...while statement will execute a block of code once, and then it will repeat the loop while a condition is true do { code to be executed } while (condition) for The for statement will execute a block of code a specified number of times for (initialization; condition; increment) { code to be executed } |