Skip to content
Advertisement

Startswith function for searching an array

I have a function that is giving me some trouble. The code below returns the error message “Cannot read property ‘value’ of undefined”. The function should just search through the values in the accountlist and return the one that starts with the submitted string. In the example, submitting “000555” should return 0.

JavaScript

Advertisement

Answer

You could use the find function:

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