← Back to challenges

Find the Smallest Number in an Array

JavaScriptHardarraysloopssortingnumbers

Instructions

Create a function that takes an array of numbers and returns the smallest number in the set.

Examples

findSmallestNum([34, 15, 88, 2]) ➞ 2

findSmallestNum([34, -345, -1, 100]) ➞ -345

findSmallestNum([-76, 1.345, 1, 0]) ➞ -76

findSmallestNum([0.4356, 0.8795, 0.5435, -0.9999]) ➞ -0.9999

findSmallestNum([7, 7, 7]) ➞ 7

Notes

  • Test cases contain decimals.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Return the First and Last Elements in an Array