+ 1
Why doesn't the TERNARY give the same results as the IF? They seem equivalent!
a===b ? 0: a<b ? -1: 1; // TERNARY if(a<b){ return -1; } else if(b<a){ return 1; } return 0; // IF STATEMENTS Ternary does nothing to the array....... The if returns the ascending order..... https://code.sololearn.com/WBck0w23H5bv/?ref=app
9 Answers
+ 3
you're missing return.
return a===b ? 0: a<b ? -1: 1;
+ 2
asɥɐ🔹ʞɐɹnnƃı🇺🇬 , please show the whole code linked to Playground, otherwise it is hard to guess the problem only seeing just a fraction of the whole.
+ 2
Yep! They are! Ćheyat
+ 1
😂😅😅😅 Thanks TheWh¡teCat 🇧🇬 Taste
I feel so stupid🙆🙆🙈🙈😂
+ 1
asɥɐ🔹ʞɐɹnnƃı🇺🇬 , the "thanks" should go to Taste . He found it before me 🐱
0
yes, its just one liner if else
0
TheWh¡teCat 🇧🇬 Added!
0
Taste , exactly 🐱
0
Ummm.. Because they are..😆😆