display the pattern number
function target() {
  ...
  var w2=g_img[0].width/2;
  g_ctx.font='14px serif';
  g_ctx.fillText(g_n,10,20);
  g_ctx.drawImage(g_img[0],g_x-w2,g_y-w2);
  canvas=document.getElementById('c');
  g_ctx=canvas.getContext('2d');
}

give_up()
function give_up() {
  g_numbers=g_pattern.split('');
  numbers();
}
the Finale

Finally, we need to recognise the player's success →


You'll have to find to find your own success image but I can show you how I implemented mine.