This is not my original idea. I followed the video by Coding Train:
https://www.youtube.com/watch?v=AaGK-fj-BAM
I saw the video and then tried writing it on my own, checking the video whenever I got stuck. I refactored the code to my liking, used newer ES6 standards (like the class keyword) and added JSdocs.