Can any one help me with this code. I am having trouble understanding why my else statement is not executing?
Hey @krnjahn753!
Welcome to the Forum!
I suggest to create a new topic.
try to do console.log(word[0] === "s" || "S")
and see what is printed
Try to write it like that
if(word[0] ===“s” || word[0] ===“S”)
Why does it show like this?
a split topic can do weird things for notifications, you can manually change the notification settings
1 Like
Got it! I think the problem that you have is in the If expression, there is
word[0] === "s" || "S"
,
and that’s true, you know why? Simply because it is like saying :
if word[0] === "s"
or "S"
and "S"
evaluates to true, in summary it’s like saying: word[0] === "s" || true
, understood?
that’s why it does execute the return true
line.