0
Does anyone know how to add conditions to variables in JavaScript.
For example, I want to say "If X is less than 15 then it is 25" or "If Y is more than 6 it is 9". something like that. Any help is appreciated. :)
4 odpowiedzi
0
It is known as Ternary Expression.. and ( ?: ) known as ternary operators
https://code.sololearn.com/WY9cbiguRcif/?ref=app
+ 2
if(x<15){
x=25;
}
if(y>6){
y=9;
}
+ 1
Yes! Thank you! That's what I meant. This really means a lot to me.
0
Thank you. But I meant it more like I could write it like this "
x = (6<7) ? 8: 12;
"
I saw it somewhere in the course and couldn't find it so I asked. sorry if I sound annoying. I just don't understand it and can't find it to look back and see it.