Accessing character of an Element of An Array

Ok here is an example of what I mean:
So lets say there is an array of numbers: var arr = [123, 345, 456, 678, 789];,
And lets say I want to access 1, from the first element of the Array.

How do I do that? arr[0].charAt(0) doesn’t work. Neither does arr[0][0] I have been searching google for the past 20 minutes and cant find anything, If anyone has any idea on how to do this, It would be greatly appreciated!

Can’t test this, but maybe the following will work:


Wow, that actually worked! Thanks a lot!

You have to convert a number to string in order to access specific characters.There are multiple ways to do so :

var arr = [123, 345, 456, 678, 789];

('' + arr[0]).charAt(0);
1 Like