[WITHOUT USING MIN/MATH Function]
The question ask me to create the function including 2 parameters.first is an array and the second parameter is either the String “Minimum” or “Maximum” . It confusing me when i don't know how to input the parameter as the string in the function. So that i decide to create 2 similar function as extremeValue(vector, maximum) and extremeValue(vector, minimum) ( I still don't know whether i can do that or not ).
And this is my code for extremeValue(vector, maximum).
So the way i did is create the array which have the same value with vector[i] than i using if statement to see if it bigger than that vector or not. However, The code is doesn't work. :(
var vector = [3, 1, 1]
var maximum
//------------this function give us the vector with all same value---------------//
function set(value, len) {
var arr = [];
for (var i = 0; i < len; i++) {
arr.push(value);
}
return arr;
}
//---------------------------------------------------//
//---------------------------------------------------//
function extremeValue(vector, maximum) {
var answer = "";
for (var count = 1; count++; count < vector.length) {
if (set(vector[count], vector.length) > vector)
answer += vector[count] + "is maximum"
}
return answer
}
//---------------------------------------------------//
console.log(extremeValue(vector, maximum))