blob: 5f6fcb45c2830ec1ae3001a906604356b5cf7b56 [file] [log] [blame]
<!DOCTYPE html>
<body>
<canvas id="canvas1" width="100" height="100"></canvas>
<canvas id="canvas2" width="100" height="100"></canvas>
<canvas id="canvas3" width="100" height="100"></canvas>
<script>
let colors = ['red', 'green', 'blue'];
let canvases = ['canvas1', 'canvas2', 'canvas3'];
colors.forEach(function(color, index, colors) {
var canvas = document.getElementById(canvases[index]);
var ctx = canvas.getContext('2d');
ctx.fillStyle = color;
ctx.fillRect(0, 0, 100, 100);
});
</script>
</body>