← Back to challenges

Length of Worm

JavaScriptHardstrings

Instructions

Given a string worm create a function that takes the length of the worm and converts it into millimeters. Each - represents one centimeter.

Examples

wormLength("----------") ➞ "100 mm."

wormLength("") ➞ "invalid"

wormLength("---_-___---_") ➞ "invalid"

Notes

Return "invalid" if an empty string is given or if the string has characters other than -.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Capital Split