Skip to content

Commit 85473af

Browse files
committed
morefunctions
1 parent 25fc0d9 commit 85473af

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

more-on-functions/studio/part-one-find-minimum-value.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,21 @@
44
let nums1 = [5, 10, 2, 42];
55
let nums2 = [-2, 0, -10, -44, 5, 3, 0, 3];
66
let nums3 = [200, 5, 4, 10, 8, 5, -3.3, 4.4, 0];
7+
function minValueArray(myArray){
8+
let minValue = myArray[0];
9+
for(let i=1;i<myArray.length;i++){
10+
if(minValue>myArray[i]){
11+
minValue=myArray[i];
12+
}
13+
}
14+
return minValue
15+
16+
17+
}
18+
719

820
//Using one of the test arrays as the argument, call your function inside the console.log statement below.
921

10-
console.log(/* your code here */);
22+
console.log(minValueArray(nums1));
23+
console.log(minValueArray(nums2));
24+
console.log(minValueArray(nums3));

0 commit comments

Comments
 (0)