Selective statements are decision making controls for JavaScript which allow for two or more alternative paths. These statements would be “if”, “if/else”, and “switch”. These statements will be executed if the condition is true. Repetitive statements are used to repeat a section of code multiple times as known as looping. These statements would be “for”, “while” and “do-while”. Is the statement true? Then the statement will repeat, if not, then it will stop.

Example of Selective Statement: This statement is telling the program that the number is greater than/equal to 2. Anything less than would fail.

int=2;

if (x<1||x>1) {

            System.out.printin(“x does not equal 1”);

}else {System.out.printin(“x equals 2”);

Example of Repetitive Statement: This statement is telling the program to begin at 3 and to repeat without going over 12.

Int a=3;

while (a <= 12) {

            System.out.printin(a);

a++

Sample Solution

This question has been answered.

Get Answer