Checking parts of JavaScript code

Tell us what’s happening:
I am currently working on the Smallest Common Multiple challenge. What I want to know how to do at this stage is to check the code I have written so far? If I run the test on @freeCodeCamp it just says the output should be this etc…I haven’t fully written the whole code yet. I want to check the first part of the code to see if that is doing what I want it to do first. How do I do that? I have looked online and most things seem to suggest I have to write a unit test to do that. That seems a bit too much for a beginner. Please note that yes I am a beginner and most of the terminology is still new to me. I am getting frustrated that a lot of the websites phrase things in a way that makes it difficult for a beginner to wrap their head around.
All I want to know at this stage is there an easy way to check whether small bits of my code are working?

Your code so far

function smallestCommons(arr) {
var max = Math.max(arr[0], arr[1]);
var min = Math.min(arr[0], arr[1]);
var range = [];
for (let i = min; i<=max; i++){



Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.113 Safari/537.36.

Challenge: Smallest Common Multiple

Link to the challenge:

What you can do is use the console.log(), don’t press the run test though, just type console.log(function()) and wait till the console pops the log itslef. It’ll log it here:

Whereabouts do I write that console.log?

You can write that at the bottom of your code. It’ll look like this:

in the editor.
whatever you put in a console.log statement will appear in the console

so you can use it to check values of variables, if something is executing etc.

Thank you so much that is really clear and easily explained. Thank you for doing that. :slight_smile:

No problem. @ieahleen also explain something that I really didn’t. You can console.log it anywhere in the code if you want to check specific part of your code. Just to clarify it.
Happy coding!!:slightly_smiling_face:

you can also use a tool like this:
this will show the values of the variables at each step
but learning to use console.log is a must