forked from TheAlgorithms/JavaScript
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFindMin.js
More file actions
Latest commit
23 lines (19 loc) · 474 Bytes
/
Copy pathFindMin.js
File metadata and controls
23 lines (19 loc) · 474 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/**
* @function FindMin
* @description Function to find the minimum number given in an array of integers.
* @param {Integer[]} nums - Array of Integers
* @return {Integer} - The minimum number of the array.
*/
constfindMin=(...nums)=>{
if(nums.length===0){
thrownewTypeError('Array is empty')
}
letmin=nums[0]
for(leti=1;i<nums.length;i++){
if(nums[i]<min){
min=nums[i]
}
}
returnmin
}
export{findMin}