Is this code correct to find the max from an array? There are other ways to find the max, however the requirements are to use "for" loop!Thanks! Full reqs : "Create an array with 10 numbers of your choice and a variable named max. Assign 0 to max. In a for loop, find the greatest number, assign it to max and write it in the console."
var numArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
var max = 0;
var arrLen = numArray.length;
for (i = 0; i < arrLen; i++) {
if (numArray[i] - numArray[arrLen - 1] >= 0) {
max = numArray[i];
} else {
continue;
}
console.log(max);
}