Ahh I see, it’s because you’re separating the string in individual characters, so basically each digit is its own number. But the challenge wants you to also take in consideration 2+ digit numbers like 90, 56 and 788 (not 9 0 5 6 7 8 8 individually) hence the need for regular expressions.
It’s not that you can’t do it without it them, but it becomes more complex.
If JS’s standard library had a
groupWith function you could easily group them by the <= 57 condition so you’d obtain an array of
['1', 'weudh', '56', ...etc] and filter out the ones whose
parseInt result yields
But since that’s not the case, you have to iterate the whole string char by char and have a separate empty array to where you’ll push each number and checking when the character changes from being a number to a non-number.