let mas = [3,5,8,20,3,16];
function getMin(a){
let result = a[0];
for(i=0;i < a.length;i++){
if(a[i]< a[0]){
result = a[i];
}
}
return result;
}
if(a[i]< a[0]){
result = a[i];}
a[0]
, а с result
.const getMin = arr => {
let result = arr[0];
for(i = 0; i < arr.length; i++){
if(arr[i] < result){
result = arr[i];
}
}
return result;
}
const getMinOld = a => {
let result = a[0];
for(i=0;i < a.length;i++){
if(a[i]< a[0]){
result = a[i];
}
}
return result;
}
let mas = [22,5,8,3,44,16];
console.log(getMin(mas)); // 3
console.log(getMinOld(mas)); // 16