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;
It looks, you miss the return statement.
return finalWord.length > 140 ? false : finalWord;
You could shorten it to
return finalWord.length <= 140 && finalWord;
returnstatement in the second example. It should bereturn (finalWord.length > 140) ? false : finalWord;return (finalWord.length > 140) ? false : finalWord;orreturn finalWord.length > 140 && finalWord;