segue meu código ficou um pouco diferente do do professor.
<!--pagina html-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<!- retangulo de canvas-->
<canvas width="600" height="400"></canvas>
<script src="lego.js"></script> <!-- arquivo externo-->
</body>
</html>
<!--fim html-->
*******************************************************************
//pagina externa em javascript//
let tela = document.querySelector('canvas');
let pincel = tela.getContext('2d');
//retangulo principal fundo canvas
pincel.fillStyle = 'lightgrey';
pincel.fillRect(0,0,600,400);
//retangulo 1
pincel.fillStyle = 'green';
pincel.fillRect(125,50,350,300);//cabeça
//retangulo 2
pincel.fillStyle = 'black';
pincel.fillRect(340,100,90,90);//olhos
//retangulo 3
pincel.fillStyle = 'black';
pincel.fillRect(180,100,90,90);//olhos
//retangulo 4
pincel.fillStyle = 'black';
pincel.fillRect(270,190,70,100);//nariz
//retangulo 5
pincel.fillStyle = 'black';
pincel.fillRect(340,240,40,110); //boca1
//retangulo 6
pincel.fillStyle = 'black';
pincel.fillRect(230,240,40,110);//boca2