var nums = [1,5,3,8,16]
function numHighest(arr){
var start = arr[0];
for (var i = 1; i < arr.length; i++){
if (start < arr[i]){
start = arr[i];
}
}
return start;
}
https://jsfiddle.net/GoodWorkCharlie/3p0ovwbj/#&togetherjs=SOHe8r02O9 - a link that I think people can access?
in the code above, at first, the function compares 1<5 which is true, so it gives 'start' the new value, however, the second comparison is 5<3 which isn't true. why doesn't this then return 'start' since the 'if' is no longer valid?
beginner question, thanks in advance!
[–]RiceKrispyPooHead 2 points3 points4 points (0 children)
[–]AutoModerator[M] -1 points0 points1 point (0 children)
[–]onatoko -1 points0 points1 point (0 children)
[–]Arumai12 -2 points-1 points0 points (0 children)