0
Why is my code not going through? it's indicating >>> uncaught TypeError! cannot read property 'getContext' of null line: 5
var canvas= document.getElementById("canvas"); var contex= canvas.getContext("2d"); var x=300; var y=350; contex.arc(x,y,50,0,2* Math.PI); contex.fillstyle="red"; contex.fill();
5 Answers
+ 2
Abraham Zimba really?? But you can see my code is working
can u share full code including html
+ 2
window.onload= function() {
let btn=
document.getElementById("Jump");
let count= 0;
btn.onclick = function () {
count +=1;
}
}
window.onload = function(){
var canvas= document.getElementById("canvas");
var contex=canvas.getContext("2d");
var x=300;
var y=350;
contex.arc(x,y,50,0,2*Math.PI);
contex.fillStyle="red";
contex.fill();
}
+ 2
Inumaki thx managed to crack the codeđ„
+ 1
you need to let html load first thats why u getting error
also I noticed u wrote fillstyle that won't work because in Javascript we use camelCase
https://code.sololearn.com/W50DLzn3y9Ts/?ref=app
+ 1
Have tried that but still not working