Me costo mucho trabajo, pero creo que aprendí bastante
//Aquí viene el texto faltante
    function dibujabarra(x, y, serie, colores, texto) {
        escribirTexto(x, y - 10, texto);
        var sumaAltura = 0
        for (var i = 0; i < serie.length; i++) {
            var altura = serie[i];
            dibujarRectangulo(x, y + sumaAltura, 50, altura, colores[i]);
            sumaAltura = sumaAltura + altura;
        }
    }
    var serie2009 = [6, 47, 41, 3, 3];
    var serie2019 = [81, 9, 3, 3, 4];
    var colores = ["blue", "green", "yellow", "red", "gray"];
    dibujabarra(50, 50, serie2009, colores, "2009");
    dibujabarra(150, 50, serie2019, colores, "2019");
</script>Aqui la ultima parte del codigo