the Finale
globals.js
var g_smiley=new Image();
g_smiley.src='images/smiley.png';
one_step()
function  one_step() {
...
      stop();
      if (g_numbers.join('')==g_pattern) finale();
    }
  }
}

Note join is the opposite to split.

finale()
function finale() {
  var w=g_side/2; var w2=w/2;
  canvas=document.getElementById('target');
  var ctx=canvas.getContext('2d');
  ctx.drawImage(g_smiley,g_x0-w2,g_x0-w2,w,w);
}

Note that drawImage allows us to specify a width and height so we can scale the image to fit. That's the last two items in the drawImage line. They are both the same because I made sure that my image has the same width and height.