Ask Question
19 February, 14:56

1.

Which of the following jа vascript statement is to compare if num is 2 or 5, if yes, increment num by 1?

if (num==2 || 5)

num = num + 1;

if (num==2 || num==5)

num = num + 1;

if (num=2 || 5)

num = num + 1;

if (num==2 || num=5)

num = num + 1;

+5
Answers (1)
  1. 19 February, 15:25
    0
    Hi!

    The following jа vascript statement compares if num is 2 or 5 and increment num by 1 if true.

    if (num==2 || num==5)

    num = num + 1;

    Explanation:

    The operator = = is used to compare if the operands are equal.

    The operator || is OR.

    If at least one of the operands is true then return true. If all operands are false returns false.

    if (num==2 || num==5) / / if num is equal 2 or if num is equal 5

    num = num + 1; / / adds 1 to num.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “1. Which of the following jа vascript statement is to compare if num is 2 or 5, if yes, increment num by 1? if (num==2 || 5) num = ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers