Reputation: 995
Can anyone explain to me what is the difference between these two statements and why the second one does not work and the first one does:
if (finalWord.length > 140) return false;
else return finalWord;
(finalWord.length > 140) ? false : finalWord;
Upvotes: 3
Views: 69
Reputation: 386520
It looks, you miss the return
statement.
return finalWord.length > 140 ? false : finalWord;
You could shorten it to
return finalWord.length <= 140 && finalWord;
Upvotes: 4