0

Js Test on Canva doesn't show up

So I was trying to add a Text to my existing canva, and looked over it about 20 times, but it still doesn't show my text. Why? window.onload = function() { var canvas = document.getElementById("canva"); var context = canvas.getContext("2d"); var x = 300; var y = 350; let btn = document.getElementById("jump"); btn.onclick = function draw () { var count = 0; count += 1 //changing the y position y -= 25; //clearing the canvas context.clearRect(0, 0, 600, 400); //redrawing the circle context.beginPath(); context.arc(x, y, 50, 0, 2 * Math.PI); context.fillStyle="red"; context.fill(); //drawing the count value context.font = "25px Arial"; context.fillStyle = "white"; context.fillText =("Count:", + count, 20, 30); }; };

28th Jun 2022, 8:27 AM
Diana
3 odpowiedzi
+ 3
Context.fillText() is function don't use "=" (In last 3rd line) Attach your code link if it doesn't work
28th Jun 2022, 8:42 AM
SAN
SAN - avatar
+ 1
In addition to SAN's answer, same line, remove first comma To be explicit, context.fillText("Count:"+count, 20, 30);
28th Jun 2022, 1:19 PM
Gordon
Gordon - avatar
0
thank yall very much!
28th Jun 2022, 6:38 PM
Diana