0
Context 2d?
Hello, the web setup in Sololearn is html5, correct? I tried making a canvas context, and set up a code like this: const canvas = document.getElementById("canvas"); const screen = canvas.getContext("2d"); But it throws a typeError on getContext?
2 odpowiedzi
+ 2
It is probably the load problem.
To fix it, use this:
window.onload = () => {
// Rest of code here
}
+ 1
Link your code.
You can only get the canvas once the html body is loaded.