BananaMaster

15 - if, else, and else if operators in JavaScript | JS lessons

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

Task 1.

Create an input type="number", a button, and a div. If the number is greater than 100 — display "big", if less than 50 — "small", otherwise "medium".

Task 2.

Create two inputs type="number", a button, and a div. If the first is greater than the second — display "first", if the second is greater than the first — display "second", if they are equal — display "good".

Task 3.

Create an input type="number", a button, and a div. If the number is less than 0 — display "ok", if the number is greater than 100 — display "no", otherwise "error".

Task 4.

Create an input and a button. If "admin" is entered — log "System control" to the console, if "boss" — "Team control", if "client" — "Basic control", otherwise — "Error".

Task 5.

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

Text

Task 6.

Create a button, a div, and a select with options "3", "6", "9", "12", "15". When the button is clicked, display the selected value from the select inside the div.

Task 7.

Create an input type="number" and a div. On any change in the input, display the following in the div: if the number is less than 10 — "small", if greater than 50 — "big", otherwise "medium".