Hey there! I'm having some trouble finding the minimum and maximum values in an array. Can you help me figure out what's going on with my code?
var repeated, studentsArray = [], marksArray = [];
while (repeated !== 'n' && repeated !== 'N'){
studentsArray.push(prompt("Enter Student Name: "));
marksArray.push(parseInt (prompt("Enter Student mark: ")));
repeated = prompt ("Do you want to enter another student: y/n");
}
function findMinimum (marksArray){
var minVal = Number.MAX_VALUE;
for(var i = 0; i < marksArray.length; i++){
if(Number(marksArray[i]) < minVal)
minVal = Number(marksArray[i]);
}
return marksArray;
}
var smallestValue = findMinimum(marksArray);
function findMaximum (marksArray){
var maxVal = Number.MAX_VALUE;
for(var i = 0; i > marksArray.length; i++){
if(Number(marksArray[i]) < maxVal)
maxVal = Number(marksArray[i]);
}
return marksArray;
}
var largestValue = findMaximum(marksArray);
document.write(largestValue);