Credits to kostasx The complete exercise with the test code can be found here : https://codepen.io/kostasx/pen/XWpQLJb?editors=1001