allison.bell
allison.bell 3d ago β€’ 0 views

Examples of Relational Operators in JavaScript (AP CSP)

Hey everyone! πŸ‘‹ Let's dive into relational operators in JavaScript. They're super important for making comparisons in your code! I've got a quick study guide and a practice quiz to help you master this topic. Good luck! πŸ€
πŸ’» Computer Science & Technology

1 Answers

βœ… Best Answer
User Avatar
trevor.aguirre Jan 6, 2026

πŸ“š Quick Study Guide

  • πŸ”’ Relational operators are used to compare two values.
  • βœ… They return a boolean value: `true` or `false`.
  • βš–οΈ Common relational operators include:
    • == (equal to)
    • != (not equal to)
    • > (greater than)
    • < (less than)
    • >= (greater than or equal to)
    • <= (less than or equal to)
  • πŸ’‘ Example: 5 > 3 returns true.
  • πŸ’» These operators are fundamental for conditional statements (if, else if, else) and loops.

Practice Quiz

  1. Which relational operator checks if two values are equal without type coercion?
    1. A. ==
    2. B. ===
    3. C. !=
    4. D. !==
  2. What will 10 < 5 return in JavaScript?
    1. A. true
    2. B. false
    3. C. 1
    4. D. 0
  3. Which operator checks if two values are NOT equal?
    1. A. ==
    2. B. >
    3. C. !=
    4. D. <=
  4. What is the result of 7 >= 7?
    1. A. true
    2. B. false
    3. C. undefined
    4. D. null
  5. Which of the following is the correct way to check if x is greater than y?
    1. A. x => y
    2. B. x > y
    3. C. x < y
    4. D. x == y
  6. What will "apple" < "banana" return?
    1. A. true
    2. B. false
    3. C. undefined
    4. D. null
  7. Which operator checks for both value and type equality?
    1. A. ==
    2. B. !=
    3. C. ===
    4. D. !==
Click to see Answers
  1. B
  2. B
  3. C
  4. A
  5. B
  6. A
  7. C

Join the discussion

Please log in to post your answer.

Log In

Earn 2 Points for answering. If your answer is selected as the best, you'll get +20 Points! πŸš€