+ 1
how we resolve the problem
solo learn editor give the error that you dont use the null in getContext while other compiler execute the code and also give the output const cany=document.getElementById('cani'); const v=cany.getContext('2d'); v.beginPath(); v.fillStyle="green"; v.fillRect(12,5,440,550); v.clearRect(102,42,127,75) v.beginPath(); v.fillStyle="purple"; v.moveTo(18,5); v.lineTo(102,80); v.lineTo(19,140); v.fill(); v.clearRect(222,42,139,23)
4 Respuestas
+ 8
//You code is working , put all your code inside html inside of js section
https://code.sololearn.com/W6Fl7Ot8mbxu/?ref=app
+ 2
The reason behind it, the section where you write the JS code loads before the DOM rendered, for dealing with this, write your code inside a script element before the closing element of body or write your code inside the window.onload function like this
window.onload=function(){
//code
}
+ 1
Ok thanks i will try
+ 1
Thanks that is executing