Console.log not working in codepen?

Console.log not working in codepen?
0.0 0

#1

Hi all. I’m working on my simon game, and I just wrote in a lot of JS, but now I want to start testing stuff in my code line by line. My usual testing method is to go down the code and put in console.log functions to make sure the right thing is being triggered, but for some reason, even if I put a console.log() right at the top of my code, nothing gets output to the console. What could be going on here? Here is a link to my pen. Note that the console.log on line 3 does nothing.

Any help is very much appreciated, thank you!


#2

Check line 81 of your JS code its invalid. If you check your browsers console (not the codepen one) it shows an error on the page there. Due to this line:

 if litID.join() == clicked.join() {

should be:

 if (litID.join() == clicked.join()) {

#3

Yep, what @bradtaniguchi.
Your code was being interpreted first, and the interpreter encountered an error in your code (line 81) which was correctly logged on the browser. It didn’t have a chance to run any functions (i.e. console.log) due to an error.


#4

Also, keep in mind that codepen also has a “console” that doesn’t show a lot of errors. Be sure to check the browser console. It’s often something like ctrl-shft-j or crtl-shft-i.