21 Day Coding Challenge

Challenge 20: Need Help


Can anyone please let me know what I m doing wrong her?


@tim_lhl @Seb any idea what I am missing here? I placed single quotes around my numbers in if statements but still not working.


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.


Is this what you meant? Still no luck, perhaps I didn’t understand what you meant.


Now you’re only returning the charaAt(i)
Return it once it checked the whole array :slight_smile:

1 Like

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.


Somehow it still didn’t workout.


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 :thinking: .


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 isNaN

And secondly your current equality checks will never result in true

1 Like

To add to what all these nice people are saying…

Will that test true or flase?


1 Like

I take it back lmao
i was wrong hahaha


1 Like

Looks like I had my Equality all wrong all along,
the more you know :thinking: !

1 Like

Still no luck. :pleading_face:


You’re still returning something every time the loop goes around. You need to get return out of the loop.

1 Like

Sounds right, but didn’t workout.


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 ! :mage:

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.

Strings in JavaScript are immutable


1 Like

Yeah I tried using just - but then yellow triangle appeared and said, use ‘===‘ to compare with ‘0’