Skip to content
Advertisement

How to create a new list everytime you loop and repeat the loop after appending elements to it?

This is my list

JavaScript

I want this output

JavaScript

If the number is even and the next number is odd loop should break, and the next odd or even number should be appended in another list. if there is even number, the list shouldn’t be broken until the next odd is found.

Advertisement

Answer

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