← Back to challenges

Most Left Digit

JavaScriptHardstringssortingnumbers

Instructions

Write a function that takes a string as an argument and returns the left most digit in the string.

Examples

leftDigit("TrAdE2W1n95!") ➞ 2

leftDigit("V3r1ta$") ➞ 3

leftDigit("U//DertHe1nflu3nC3") ➞ 1

leftDigit("J@v@5cR1PT") ➞ 5

Notes

  • Each string will have at least two numbers.
  • Return the result as an integer.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Video Length in Seconds