JavaScript Spiral / jsfiddle vs verbatim HTML file | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

JavaScript Spiral / jsfiddle vs verbatim HTML file

Originally I thought making a spiral with JS would be a good learning project. I'm not great with math so it would take me a looong time to figure out the equations myself so I just retyped a jsfiddle verbatim to see some code and get it in muscle memory. After I finished though, it won't work for me client side. I'm getting this error from Chrome: spiral.js:2 Uncaught TypeError: Cannot read property 'getContext' of null at spiral.js:2 From this code line: var context = c.getContext("2d"); the jsfiddle: http://jsfiddle.net/jingshaochen/xJc7M/ But this js fiddle is the exact same and it generates a spiral and works. Is this something to do with a frame work around it?? I would appreciate any input greatly.

4th Jul 2018, 6:59 PM
Colin
1 Answer
+ 3
JSFiddle adds JS after the elements are loaded, so maybe some of the recommendations in this post can help you: https://www.sololearn.com/post/7444/?ref=app
5th Jul 2018, 12:31 AM
Mickel
Mickel - avatar