Javascript switch statement switch on number

Description

Javascript switch statement switch on number



let secretNumber = 1;

switch (secretNumber) {
    case 1:/*  w  w  w.j  a v a 2  s .  c om*/
        console.log("Too low!");
        break;

    case 2:
        console.log("Too low!");
        break;

    case 3:
        console.log("You guessed the secret number!");
        break;

    case 4:
        console.log("Too high!");
        break;

    case 5:
        console.log("Too high!");
        break;

    default:
        console.log("You did not enter a number between 1 and 5.");
        break;
}

        console.log("<br />Execution continues here");



PreviousNext

Related