I am watching the freeCodeCamp youTube videos and want to practice it myself. I have got codePen and have saved a .js file and written out the code from the tutorial. Nothing displays in the console. How do I run a .js file in the console like Beau is in the videos?
Assuming you mean that you just have some JS code written in to the JS section on the Codepen, you are looking to run it and get a display in the console?
Turn off >settings>behavior > auto updating preview (top right)
Turn on Console (bottom left)
Hit Run (top center)
Here’s a quick example:
This should evaluate your JS and output any calls to console log, etc
var myName;
myName = “Mike”;
console.log("My name is " + myName);
which would display, My name is Mike
That’s all I want to do, write simple code to practice how different things work and display it in the console so I can see the result.
I have looked at what you suggested, I can’t find auto updating preview (top right). I don’t know whether being on the free online version makes a difference?
Is there any other software that I can use for this? I have got DreamWeaver and Brackets on my Mac, but I am having the same problem using them.
My guess is that in CodePen, you created a new ‘project’ instead of a new ‘pen’. The suggestions above assumed you created a pen. Try going to ‘create’ then ‘new pen’. Also, most of the JavaScript videos on freeCodeCamp YouTube have a link in the description to the code on CodePen. Once you click the link, click the ‘fork’ button at the top to make your own copy. Then you can make changes and see the result.
Another thing to check is that you have clicked the ‘console’ button at the bottom to open the console.
I have downloaded the example html, css and javascript files from p5js then downloaded google chrome. I opened the downloaded files in DreamWeaver 2017 and wrote my code in the .js file, then I ran it in chrome and opened the inbuilt javascript console in chrome.