BananaMaster

16 - Comparison operators > >= < <= == != === (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 0 — display "positive", if less than 0 — "negative", if equal to 0 — "zero".

Task 2.

Create an input type="number" (age), a button, and a div. If the age is 18 or more — display "good", otherwise — "no".

Task 3.

Create an input type="number" (battery level 0–100), a button, and a div. Display: <= 10 — "too low" , <=30 — "low" , <=60 — "medium" , otherwise — "full" .

Task 4.

Create an input type="number" (score from 0 to 100), a button, and a div. Display grade: >= 90 — "A", >= 75 — "B", >= 60 — "C", >= 50 — "D", otherwise — "F".

Task 5.

Create an input type="number" (speed in km/h), a button, and a div. If the speed is 90 or more — display "danger", if greater than 60 — display "warning", otherwise — display "safe".

Task 6.

Create two input type="password", a button, and a div. If the passwords do not match (!==) — display "error", if they match — display "ok".

Task 7.

Create a checkbox, a button, and a div. If the checkbox is not equal to true (!== true) — display "off", otherwise — display "on".