Can you use incrimental assignment instead of a for loop?

Hello campers,

I am going through the JS course and I was wondering if instead of making a for loop or a for… in loop with arrays and objects to cycle through indexing, can we use eg. myArray++, myObj++. It looks like that in step 84 of building a role playing game. Or possibly myArray … ++.?

you still need a loop to go through all the indeces

if myArray is an array, myArray++ doesn’t work, the ++ works only on numbers

1 Like

If you use myArr++ in C, you probably shouldn’t. That’s not a modern mesh practice in most cases

So C allows it but it’s not best practice?

Correct.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.