BananaMaster

21 - What is switch and why you need to know it (JS lessons)

If you forgot something — click to go to the lesson.

Task 1.

Create a select with options "cat", "dog", "bird", a button, and a div. Using switch, display the number of the animal: "cat" — "1", "dog" — "2", "bird" — "3".

Task 2.

Create an input type="text" and a button. If "admin" is entered — change the button background color to red, if "boss" — to blue, if "client" — to green. (red, blue, green)

Task 3.

Create an input type="text", a button, and a div. If "km" is entered — display "kilometer", "m" — "meter", "cm" — "centimeter".

Task 4.

Create a select with options "easy", "medium", "hard", "expert" and a div. Using switch, display the number of lives: 5, 3, 2, 1.

Task 5.

Create a select with options "breakfast", "lunch", "dinner", a button, and a div. Using switch, display the meal time: "8:00", "13:00", "19:00".

Task 6.

Create a select with options "kg", "g", "t" and a div. Using switch, display the full name of the unit: "kilogram", "gram", "ton". Implement it in real time, i.e., when the value in the select changes.

Task 7.

Create a select with options "+", "-", "*", "/" and two input type="number", a button, and a div. Using switch, perform the selected operation and display the result.