<canvas id="canvas" width=300 height=300 style="border: 1px solid black; background: #EEEEEE"></canvas>
<script>
let canvas = document.getElementById('canvas')
let ctx = canvas.getContext('2d')
//We swapped our function arguments for a single object
function drawRect(rect) {
ctx.fillStyle = rect.color
ctx.fillRect(rect.x, rect.y, rect.width, rect.height)
}
//We declare our objects with their respective properties
let rect1 = { x: 100, y: 50, width: 80, height: 40, color: "red" }
let rect2 = { x: 100, y: 150, width: 80, height: 40, color: "blue" }
drawRect(rect1)
drawRect(rect2)
</script>