[Solved]Why str.charAt(-1) doesn't work? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 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 Respostas
+ 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