Skip to content
Advertisement

Repeat list elements based in another list

I would like to repeat elements from one list based in a second list, like this:

JavaScript

I’ve got this result:

JavaScript

I’d like to get this result:

JavaScript

Advertisement

Answer

You may iterate on both list together, using zip, then increase i until you reach the bound of the current value

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