Skip to content
Advertisement

Iteration numbers with True False condition

Please HELP!!

I have a list:

JavaScript

I want to generate iteration number if it’s False the number continues and if it’s True the number stays. I Try this code:

JavaScript

it’s just keep running and did not show any output. the desired output will be [1,2,3,3,3,4,5,6,6]

I have no idea what’s wrong with it Thanks

Advertisement

Answer

Yet another version of this (with the output behaving as required by OP):

JavaScript

Usage:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement