← Back to challenges

Grab the Numbers

JavaScriptHardstringsnumbers

Instructions

Given a string including a bunch of characters and numbers, return the sum of all the numbers in the string. Note that multiple digits next to each other are counted as a whole number rather than separate digits.

Examples

grabNumberSum("aeiou250abc10") ➞ 260

grabNumberSum("one1two2twenty20") ➞ 23

grabNumberSum("900uwu50uwuuwuuwu25uwu25") ➞ 1000

Notes

Remember not to just add single digit numbers together, it should be possible for answers to easily get into the 100s!

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Preventing the Collapse of the Universe