I suspect that your issue is that the challenge wants you to only increment, myVar++
instead of increment and assignment (which is unnecessary) myVar = myVar++
In a for loop, the increment variable update always occurs at the same time every iteration. Pre increment and post increment in the head of the loop produces the same results. You can change how the increment variable is updated but not when.
for (let i = 0; i < lim; i++) {
...
}
is the same as
for (let i = 0; i < lim; ++i) {
...
}
In the past, for equivalent C/C++ code, there used to be a minor performance difference between the two, but with modern compilers the performance is the same.
Hi, I have taken all suggestions on board. Still not working out. My earlier answer was ++myVar. This was accepted, but it insists on “This should be changed: myVar = myVar + 1;” . I changed this and replaced it with this: ++myVar (my earlier answer). It still insists that this, myVar + 1, be changed. But this is what I replaced and is no longer there.