Skip to content

Commit cb3f79f

Browse files
authored
Create remove-the-minimum.js
1 parent 5c7fa66 commit cb3f79f

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

remove-the-minimum.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//remove the lowest rating.
2+
3+
function removeSmallest(numbers = []) {
4+
let tempArray = [];
5+
6+
numbers.forEach((fn => {
7+
tempArray.push(fn)
8+
}))
9+
10+
if(!tempArray) {
11+
return []
12+
}
13+
14+
let findMin = Math.min(...tempArray);
15+
console.log(findMin)
16+
const index = tempArray.indexOf(findMin);
17+
if(index > -1) {
18+
tempArray.splice(index,1);
19+
}
20+
21+
return tempArray
22+
}
23+
24+
25+
let result = removeSmallest([1,2,3,4,5,6])
26+
27+
console.log(result)

0 commit comments

Comments
 (0)