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 trialSantiago Enciso
17,789 PointsbeginPath() not working
var context = $("canvas")[0].getContext("2nd");
context.beginPath(); context.moveTo(10, 10); context.lineTo(20, 10); context.lineTo(20, 20); context.lineTo(10, 20); context.closePath() context.stroke
When I inspect the element in the JS Console, it says "Uncaught TypeError: context.beginPath in not a function"
Please help
3 Answers
eck
43,038 PointsYou are trying to get "2nd" for your context instead of "2d".
Try
var context = $("canvas")[0].getContext("2d");
alessandradaudt
14,500 PointsI was having the same problem because I had the same mistake!
eck
43,038 PointsWere you able to get it working?
alessandradaudt
14,500 PointsYes, once I realized the mistake, it worked like a charm!
Santiago Enciso
17,789 PointsSantiago Enciso
17,789 PointsThanks Erik!