0

JavaScript

I am trying to code a red circle I keep getting a syntax error “null is not an object” Here is my JavaScript code: var canvas = document.getElementById("canvas"); var context = canvas.getContext("2d"); var x = 300; var y = 350; context.arc(x, y, 50, 0, 2 * Math.Pi); context.fillStyle="red"; context.fill(); Here is my html code: <canvas id = “canvas” height = “400” width = “600”> </canvas>

20th Mar 2023, 4:16 PM
Elin
3 Answers
+ 4
Use “Math.PI” instead of “Math.Pi”
20th Mar 2023, 4:37 PM
SoloProg
SoloProg - avatar
+ 1
I tried that but it still didn’t work but thank you for your help
23rd Mar 2023, 12:26 AM
Elin
+ 1
I solved it finally
23rd Mar 2023, 1:00 AM
Elin