if have variables , loop condition set-up this:
var scores = [23, 53, 85]; var arraylength = scores.length; var i; for(i = 0; < arraylength; i++) does i refer scores array indexed position of 0, or i counter number, set 0?
i'm kinda confused on understanding what's happening.
any appreciated!
here can see in action:
var scores = [23, 53, 85]; var arraylength = scores.length; var i; for(i = 0; < arraylength; i++) { console.log('i = ' + + ', scores[i] = ' + scores[i]); } console.log('end of loop: = ' + i); one important thing understand i incremented until condition i < arraylength not met anymore. will reach value 3 loop end immediately. therefore, code inside loop not executed i = 3.
Comments
Post a Comment