+ 2

[Solved]Why str.charAt(-1) doesn't work?

It's a challenge code Named "Gapful Numbers". My code only works for 3 numbers. Why the negative index doesn't work? https://code.sololearn.com/W91RQKB05NE3/?ref=app

27th Sep 2019, 5:16 PM
Raihan ArefinđŸ‡§đŸ‡© [Thunder_Rabbit⚡⚡]
Raihan ArefinđŸ‡§đŸ‡©  [Thunder_Rabbit⚡⚡] - avatar
3 RĂ©ponses
+ 3
You are trying to access the character at index -1, and that doesn't really exist. You can either use numStr.slice(-1), or numStr.charAt(numStr.length - 1)
27th Sep 2019, 5:24 PM
Airree
Airree - avatar
+ 2
Ok, Ok Thank u so much❀
27th Sep 2019, 5:35 PM
Raihan ArefinđŸ‡§đŸ‡© [Thunder_Rabbit⚡⚡]
Raihan ArefinđŸ‡§đŸ‡©  [Thunder_Rabbit⚡⚡] - avatar
+ 1
no
27th Sep 2019, 5:30 PM
Airree
Airree - avatar