0
This is JavaScript code is not running on sololearn....can anyone tell why??
"use strict"; { const txt = 'STRINGS'; const viscosity = 0.005; const stiffness = 0.99; class Point { constructor (i, x, y) { this.c = null; this.x0 = x; this.y0 = y; this.x = x + Math.sin(i) * 100; this.y = y + Math.cos(i) * 100; this.vx = 0.0; this.vy = 0.0; this.a = 0.0; this.s = 0.0; this.p0 = this; this.p1 = this; this.t = 0; } texture (c, color) { this.c = document.createElement("canvas"); const ctx = this.c.getContext("2d"); this.c.width = this.c.height = 400; ctx.font = "500px Arial Black, Arial"; ctx.fillStyle = color;
6 Respuestas
+ 1
Utkarsh Bansal place your javascript code inside the following function
onload=()=>{
}
the above function will only run when html document if fully loaded unlike what is happening in your case is that javascript is getting executed before dom loading ,which means the element body doesn't exist yet.
And this is happening since sololearn puts js file inside head tag.
+ 1
Yeah.... it's working fine now....thank you
0
Did you appended canvas to body element of document?
0
Yes I did
0
https://code.sololearn.com/W63kxc5hfh6D/?ref=app
This is the complete code.....
0
Of the question asked above