Sure, here is an example of JavaScript code for a simple paint function that allows the user to draw on an HTML canvas element:
// Create a canvas element and set its dimensions
var canvas = document.createElement('canvas');
canvas.width = 800;
canvas.height = 600;