Group Tasks

const w2h = (_, i) => i * cnv.height / cnv.width
let values = Array (cnv.width).fill ().map (w2h)
const rand_el = a => {
   const i = Math.floor (Math.random () * a.length)
   return a.splice (i, 1)[0]
}
const jumble = a => {
   const r = []
   while (a.length) r.push (rand_el (a))
   return r
}
const rectify = (s, w, c) => {
   if (s.length >= w) return s
   else return (Array (w).join (c) + s).slice (-w)
}

You may want to draw on the following resources: