Skip to content
Advertisement

Cannot invoke charAt(int) on the array type String[]

I’m doing a function that counts digits in a string:

JavaScript

The error is:

JavaScript

Any ideas how to fix that?

Advertisement

Answer

You are trying to invoke the charAt() method on a String[]. String[] does not have such a method, but String does. What I believe you wanted to do is:

JavaScript

This will get the char at position i in the String at position i from your String array

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement