-
I might be way off the mark with this, it's a long time since I did anything with JavaScript but does your use of indexof fail when there is only one number in the input string? As cyclotron mentioned an input of "1" and "one" should both produce 11, indexof will only find the first index and you need to also find the last index (which in this case is the same).
-
Don't have time to go through your code (and I've never really done
.js
) but if you post your input in a gist and the individual numbers each line produces I can see what mine does differently and give you a hint.(You obviously don't just want to be told what the answer should be as there's no fun in that.)
In case anyone has morbid fascination, gist with my code (javascript): https://gist.github.com/ZooeyMiller/aaaf22e14fc5401f06dcd16c3ed8b605
Last year I tried it in haskell, thought I'd make my life easier by doing it in JS this year 🙃