3rd variant of my JavaScript experimentation
Based off this wonderful code by Radik which I decided to play and tweak around