Can anyone please let me know what I m doing wrong her?
Your last statement, is essentially saying, if non of those other conditions apply, then apply this last one. Instead, it should be if this last condition also doesn’t apply, then do nothing to it. Hopefully that makes sense.
You should also ‘return’ something at the end.
Now you’re only returning the charaAt(i)
Return it once it checked the whole array
So it should return in the big if statement not the nested ones?
Yep, you got it.
Now, ‘return’ will end the function, so you only want to do that after you’ve processed the whole string.
Oh and your return is in the loop
Also just a quick insight on you’re code!
I’m not 100% sure since i can’t test it,
but instead of replacing only the [ .charAt(i) ] !~
Wouldn’t it be better to replace all the let say 1 with i in the string directly !
This way you wont have to go over another 1 again .
There are a couple issues here:
Number.isInteger doesn’t do what you think it does. Either use it in conjuction with
parseInt or use
And secondly your current equality checks will never result in true
To add to what all these nice people are saying…
Will that test true or flase?
I take it back lmao
i was wrong hahaha
Looks like I had my Equality all wrong all along,
the more you know !
You’re still returning something every time the loop goes around. You need to get return out of the loop.
Ok, you’re making progress!
As @Seb suggested, take a look at his link regarding the ‘===’ and ‘==’.
Get ready for some wizardry with the ascii table
Try on your first if !
if(message.charCodeAt(i) >= 48 && message.charCodeAt(i) <= 53 )
The message you are returning is the same as the message that is passed through in the function parameters.
Yeah I tried using just - but then yellow triangle appeared and said, use ‘===‘ to compare with ‘0’