Reputation:
I have below code, it's too simple
var Height = <%= Height %>,
_height;
console.log(Height); // in my test, I got 800
if(Height > 800){
_height = 450;
}
else {
_height = 330;
}
console.log(_height); // it will log 'undefined'
What is the wrong part?
Upvotes: 0
Views: 112
Reputation: 1068
Convert Height
to int or float then compare
if(parseInt(Height)>800)
or
if(parseFloat(Height)>800)
Upvotes: 0
Reputation: 820
use if (parseInt(Height) > 800)
instead of simply checking if(Height > 800)
. Its working fine.
Upvotes: 0
Reputation: 8992
You have a typo at (Missing letter)
heigh = 450;
so, try the code below:
var Height = <%= Height %>,
_height;
console.log(Height); // in my test, I got 800
if(Height > 800){
_height = 450;
}
else {
_height = 330;
}
console.log(_height);
Upvotes: 1