Ask 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 = 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. 7 September, 23:54
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers