A JS method for toggling between an array of values