+ 1
So good right?
counting characters, epecially when referring to arrays or strings, is extremely helpful. Say i have an array of test scores var myArray = [92,87,91,88,0,95]; And let's say I want to do something with that array, like compare each score with the current class average: var classAvg = 85; well I could write a loop like this: while i < 6: //code to be executed i++; and that will work, since my array index ends at [5], since it has 6 values. but that means I have to go back into my code each time
1 Odpowiedź
+ 1
Do you mean something like this?
https://code.sololearn.com/W3bOeLwQ3760/?ref=app