Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

General Discussion

Whats wrong with my code

This is the second course i have done that isn't working in the browser preview, is there something wrong with my code or is there a reason this happens with brackets/sublimetext (i have tried both) ? This is the code and there should be a rectangle on the canvas but its blank

var canvas = document.getElementById("canvas");
var context = canvas.getContext("2d");

imgFrog = new Image();
imgFrog.src = "mikethefrog.png";
imgFrog.addEventListener("load", init, false);

var requestAminFrame =
    window.requestAnimationFrame ||
    window.webkitRequestAnimationFrame ||
    window.mozRequestAnimationFrame ||
    window.oRequestAnimationFrame ||
    window.msRequestAnimationFrame ||
    function (callback) {
        window.setTimeout(callback, 1000/60);
    };

function init() {
    requestAminFrame(update);

}

function update() {
    context.fillRect( 10, 10, 40, 380, "#111111");
    context.fillRect( 10, 10, 380, 40, "#000000");
    context.fillRect( 10, 350, 380, 40, "#000000");
    context.fillRect( 350, 10, 40, 380, "#000000");
    context.fillRect( 180, 10, 40, 180, "#000000");

    requestAminFrame(update);

}

I have tried setting the fill color seperate to.

EDIT- Fixed markdown so that the code is more readable.

Hi thanks didn't know I could do that, I got the problem sorted, it was the path for the img that was stopping it all loading.