← Back to challenges

Recursion: Length of a String

JavaScriptMediumrecursionstringslanguage_fundamentals

Instructions

Write a function that returns the length of a string. Make your function recursive.

Examples

length("apple") ➞ 5

length("make") ➞ 4

length("a") ➞ 1

length("") ➞ 0

Notes

Check the Resources tab for info on recursion.

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