My code only runs at codecademy

I changed the values, but the code structure is from codecademy JavaScript conditions practice, ‘Race Time’. My code runs at codecademy console, but it does not work at outside online JavaScript compilers. I don’t know why. Could anyone help me?

let stroller = true;
let dog = true;
if (stroller || dog) {console.log('Race is 2-mile walk.');}
else {console.log('Race is 5-mile run.');}

Did you see an error message when you tried to use it? I copy/pasted your code into’s JavaScript editor and it worked fine

1 Like


I just copied it into the console in my Chrome Browser, and it seems to work fine

How did you try and run it? I’ll try and replicate it

1 Like

Hello! Thank you for your reply. When I tried some of the online JavaScript compilers, they didn’t show the result of my coding in the console. But, when I tried in as ‘selectall’ advised, it showed the result and I am so happy to see it. I didn’t try in Chrome Brower. I will do that, too as you advised.

Thank you so much for your help. Now, I can see the result of my coding. I am so happy!

Since your code runs fine, do you know how to access your browser’s console log? I believe most if not all browsers make it accessible through the [F12] key. Google “browserName dev tools” if it doesn’t work. Once there, select console on the menu, and you should see your output (and errors when applicable).

Also, the script needs to either be pasted into the console, or embedded in an html page, which is simple. See just about any js example on W3schools to see how that should work. Later Codecademy tutorials cover how to embed JS code directly in HTML (as in the W3 examples) and embedding the script.js files themselves.

You can also stick it the output in an alert() for a popup with your output if there isn’t an annoying amount of them to generate. Example: alert('Race is 2-mile walk.');