Quick help


#1

Which of the following JavaScript "for loops" will have the maximum iterations?
a for (var i = 4; i <= 24; i = i + 1) {
}
b for (var i = 4; i < 24; i = i + 2) {
}
c for (var i = 4; i < 24; i = i + 1) {
}
d for (var i = 4; i < 24; i = i + 24) {
}

The answer should be A because every other one will stop at 23 correct ?


#2

correct, A would be the answer


#3

Thanks alot man!
but is my logic correct as well or is there any other reason it is a ?


#4

The variable is always set at 4 so that doesn't matter,

the condition is the same every time except for (a)

Otherwise the increment value is the final factor, A and C both increment at the smallest value.

that's the only other thing needed to be worried about.


#5

Again thanks for the help, I did not expect any kind of response so soon =)