← Back to challenges

Smaller String Number

JavaScriptHardstringslanguage_fundamentals

Instructions

Create a function that returns the smaller number.

Examples

smallerNum("21", "44") ➞ "21"

smallerNum("1500", "1") ➞ "1"

smallerNum("5", "5") ➞ "5"

Notes

  • Numbers will be represented as strings, and your output should also be a string.
  • If both numbers tie, return either number.
  • Numbers will be positive.
  • Bonus: See if you can do this without converting to integers.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Convert Number to String of Dashes