Learn JavaScript SWITCHES in 6 minutes! 💡

Поділитися
Вставка
  • Опубліковано 2 сер 2024
  • 00:00:00 example 1
    00:03:28 break
    00:04:14 example 2

КОМЕНТАРІ • 15

  • @BroCodez
    @BroCodez  9 місяців тому +8

    const day = 7;
    switch (day) {
    case 1:
    console.log("It is Monday");
    break;
    case 2:
    console.log("It is Tuesday");
    break;
    case 3:
    console.log("It is Wednesday");
    break;
    case 4:
    console.log("It is Thursday");
    break;
    case 5:
    console.log("It is Friday");
    break;
    case 6:
    console.log("It is Saturday");
    break;
    case 7:
    console.log("It is Sunday");
    break;
    default:
    console.log(`${day} is not a day`);
    }

    • @user-bw5zh7mu7s
      @user-bw5zh7mu7s 3 місяці тому

      Why did you use "const" over comment and in the video you used "let"? I am sorry i am a beginner.

    • @RainNebula
      @RainNebula 2 місяці тому +1

      @@user-bw5zh7mu7s "let" is used to define a variable in JavaScript. "const" is also used to define a variable. The only difference is "const" makes a constant variable, that is one that stays constant and can't change. For the purpose of just the switch statement it doesn't really matter. However, if the switch statement had something like " case 7: day += 1; break; " then "const" wouldn't work as it cannot be changed, it stays constant at what it was initially set to. That's my understanding at least. Looking into the differences between the two can potentially give more insight.

  • @mehnajiktafena
    @mehnajiktafena 9 місяців тому +1

    Dude I can't thank you enough right now❤❤❤

  • @djo_shorts6154
    @djo_shorts6154 9 місяців тому +1

    Love you bro 🙌✨

  • @iagomartinez3019
    @iagomartinez3019 7 місяців тому

    great video bro!

  • @SourovChandraBarmon
    @SourovChandraBarmon 19 днів тому

    Thanks a lot sir🥰

  • @fachihul
    @fachihul 9 місяців тому +1

    Is it brand new course?

  • @futuredoctor7148
    @futuredoctor7148 5 місяців тому

    thnx bro

  • @ProgrammingMatters
    @ProgrammingMatters 9 місяців тому

    🤗🤗🤗

  • @1T_pressly
    @1T_pressly 9 місяців тому

  • @andrediegues2740
    @andrediegues2740 5 місяців тому +1

    Hey, I've been watching your videos about learning code, and I find them really helpful, thank you. However, I was thinking through the example that you gave with the Grade System, and I find there's something missing there. The grades are usually from 100 to 0, so the default part of the work does not have any mistakes, but there is a maximum grade. And if I put 101 or any other superior value, it's still A, how do I put it so that it stops in 100?

    • @codingchannel7351
      @codingchannel7351 5 місяців тому +2

      You could add a case testScore > 100 with something like "score can't be over 100" for the letterscore

    • @andrediegues2740
      @andrediegues2740 5 місяців тому

      @@codingchannel7351 Thank you!

  • @mathMetallica123
    @mathMetallica123 27 днів тому

    Couldn't help myself; case 3 logs It is Wednesday, my dudes.