python is my goto language, but as I'm more a backend dev, I struggle with javascript. Solution ask chatgpt to translate python to JS and ask it to write the test cases so you can learn and verify the code is correct too!