Finally, we deal with making it reappear at the top after it disappears at the bottom, and in a new random x-position:
if (melon_y > myCanvas.height) {
melon_y= 0;
melon_x= Math.random() * myCanvas.width;
}
The code above says: if the melon's new y-position is
greater than the height of the canvas (remembering the canvas is zero at the top and increases going down), then
reset y to zero.
We also choose a new x-position by taking a random number between 0 and 1, and multiplying that by the canvas width.
Of course, it'll work with any size canvas.