Well, I like to not just memorize blocks of code, but to understand them, so that I can create them myself. Why does this work? I don't understand. If someone can explain it to me, I'd be most grateful. To me it looks like: If the array index (position in the array) is greater than 0, 0 = the array index, and how that would magically tell me the highest number in the array I haven't a single clue. I've tried searching for an answer on this but without luck. Here's an example of the code, thanks in advance:
var array = [3, 4, 5, 21.15, 21, 9];
var largest = 0;
for (i = 0; i < array.length; i++) {
if (array[i] > largest) {
largest = array[i];
}
}
console.log(largest);