A quick solution of the spider monkey problem in JavaScript TODO: Remove the state variable "cancelled" through folding