[Solved] Javascript – biggest number from array using loop [closed]


To start, we’ve seen no numbers, and the code assumest the biggest is 0 or larger:

var biggest = 0;

We’ll look at each number in the list:

for(i=0; i < num.length; i++ ) {

Is the current number bigger than the biggest we’ve seen?

  if( num[i] > biggest ) {

If so, it’s the new biggest number

    biggest = num[i];   
  }
}

When the loop is done, biggest contains the largest number we saw along the way.

4

solved Javascript – biggest number from array using loop [closed]