I have an array whose elements are made up of various character (numbers and letters). How could I check whether the first character for a given element is a number? I was trying to use splice/slice but for some reason I was unable to get the solution. I had something like this:
if (!isNaN(array[i].substr(0, 1))) {
array.slice(0,0); //here I want to remove the element whose first character is a number and not a letter - should I use pop?
}
Can someone please advise? Thanks in advance.
Here is an example:
array[0] ="adkfjdkjfdkj"
array[1] = "12fjkdjfkd"
array[2] = "kcnvmcvn"
So for those elements of array[], I would want to check all three and remove array[1] since the first character is an integer; and then array[2] would become array[1]. I would think a method similar to pop() would be useful here
typeof array[0]returnnumberas a string if first element is a numberarray.splice(0, 1);