108k views
2 votes
Which of the following is a valid JavaSript statement?

a. If (x = 5) x == 2 * x;
b. if (x = 5) x =2* x;
c. if (x == 5) x == 2 * x;
d. if (x == 5) x = 2 * x;​

2 Answers

2 votes

It is D if (x == 5) x = 2 * x;​

User Ponytech
by
6.0k points
6 votes

Answer:

D

Step-by-step explanation:

A and B are not valid because you cannot use "=" as a comparator (you must use "==" or "===").

C is not valid because the expression after the conditional is not a statement (it uses "==" instead of "=")

User Kas Elvirov
by
6.1k points