vendredi 9 novembre 2018

Unexpected token var when creating variable in if condition

I am creating variable and using it in for statement

for(var i = 0; i < 10; i++) {
   console.log(i)
}

It is working properly and resulting from 1-10;

When I write same in the if condition

if(var value = 10) {
   console.log("Evaluate");
}

It is resulting Unexpected token var. When I declare a variable (var a = 10), resulting the same error. Is there any issue.

Aucun commentaire:

Enregistrer un commentaire