This is a good, succinct description of a useful technique. I would however think about adding some detail of what's happening in that loop. The final code looks like you're just going to return the value from the last iteration; which I'm sure isn't what's intended ;)
Depending on what it does you could even extend the example to directly return the output from an array function (e.g. reduce, map etc.)
Haha, you're in my head. As I was writing the example I was deciding how far I wanted to carry it for correctness. I opted for keeping the code near the if's at a more abstract level. Partially hoping people wouldn't fixate on it ;)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
This is a good, succinct description of a useful technique. I would however think about adding some detail of what's happening in that loop. The final code looks like you're just going to return the value from the last iteration; which I'm sure isn't what's intended ;)
Depending on what it does you could even extend the example to directly return the output from an array function (e.g. reduce, map etc.)
Haha, you're in my head. As I was writing the example I was deciding how far I wanted to carry it for correctness. I opted for keeping the code near the if's at a more abstract level. Partially hoping people wouldn't fixate on it ;)