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

JavaScript

Why won't rectangle draw on the canvas?

I'm messing around with some cross-platform things, and one of the feature includes declaring a function with the drawRect code in file2.js and calling the function in file1.js. I have my script tags inside the body of the html, after the canvas, and after I load jQuery. It's throwing an error that it doesn't recognize getContext, which is what I use to get the context in the function in file2.js. Not sure why it won't draw the rectangle and gives that error, Thanks,

Gabriel

1 Answer

Stan Day
Stan Day
36,802 Points

Kinda hard to answer without actually seeing the code.