Can anyone please help me read this shorthand code?
datain = $this.hasClass('up')?+1:($this.hasClass('down')?-1:null);
sorry for the obvious question but I can’t work it out myself.
I wish the datain to return “+1” if it has the up class but instead it only returns “1”
The code is using the conditional operator.
If you want datain to return +1, then you probably need to assign it a string instead of an integer. Just wrap the values in quotes. (
"+1","-1")