0

Why it is not drawing a line? Please help 🙏

https://code.sololearn.com/W25cFSfe0K72/?ref=app

25th Jan 2022, 2:40 AM
|| H A C K E R Z 2 0 2 1 ||
|| H A C K E R Z 2 0 2 1 || - avatar
2 Réponses
+ 3
1. When u declare a variable inside window.onload u cannot use it outside because it is out of scope 2. U need to use ctx.lineto() not ctx=lineto() [SAME WITH OTHERS .stroke() , .moveTo() ] window.onload = function() { var canvas = document.getElementById("canvas"); var ctx = canvas.getContext("2d"); ctx.moveTo(0,0); ctx.lineTo(600,400); ctx.stroke(); }
25th Jan 2022, 2:45 AM
Pariket Thakur
Pariket Thakur - avatar
+ 1
Thanks 😊
25th Jan 2022, 3:16 AM
|| H A C K E R Z 2 0 2 1 ||
|| H A C K E R Z 2 0 2 1 || - avatar