0

How to use if statement in js

27th Dec 2016, 4:31 AM
Vipul Aggarwal
Vipul Aggarwal - avatar
4 Answers
+ 3
if (condition) { //Statements go here }
28th Dec 2016, 5:29 PM
iiRosie1
iiRosie1 - avatar
0
If statements in JS are conditional statements just like in other languages. What dont you understand specifically? e.g. if(condition){ // if something is true, e.g if x===1, then... //execute this block of code } //if x === 1 is not true, ignore the above block of code and... // run this other code... Like that.Hope its clear
27th Dec 2016, 5:07 AM
ONLY JS PLEASE!
ONLY JS PLEASE! - avatar
0
if (condition) { statements } Example: var x==1; if (x==1) { document.write("x is equal to 1"); }
27th Dec 2016, 5:43 AM
Bhadresh Arya
Bhadresh Arya - avatar
0
if (something happens) { Do something }
28th Dec 2016, 9:37 PM
Cherry
Cherry - avatar