Question About This Screenshot

I don’t understand how the solution works.
On the bottom left (passing criteria) there is the nextInLine([], 5) and others saying should return number X .
Where and how do you write these to see these results? As is? Or another way I’ve forgotten about…
The solution passes the assignment withOut writing any of these anywhere or am I missing something?
Hope this makes sense, trying to wrap my head around JavaScript, sometimes I just cant see how it works even when it passes or cant see how it would be used in websites and stuff.
Thanks in advance.

Please don’t paste screens shots. It makes it harder for us to work with.

Can you post the link to the challenge description please?

oh sorry about that here you go.

1 Like

You are only tasked with writing the function itself. In programming, functions get “called” by other pieces of code. Maybe I’m tasked with writing the function getHalf and it is supposed to take one number and return that number divided by 2.
I write

function getHalf(num) {
    return num/2;
}

Another piece of code would call my function with

var halfOfSix = getHalf(6);

and my function would return 3.

In the freeCodeCamp lessons, there are tests that will call your function several times with different values and see if it is returning the correct result. You don’t need to add those tests yourself.

While you’re working on the challenge though, you can run the tests yourself to make sure you’re doing the right thing. There are a few ways you can do it. The fastest is to add the test to the bottom of the code in the editor with a console.log(nextInLine([], 5)) (etc). You can then view the console by hitting F12 on your keyboard (“DevTools”) and looking at the console. However I think it’s much easier to test your code using a tool like repl.it. This is a “Run Edit Print Loop” (REPL) that lets you see you use a process of changing code, running it, and seeing what happens.

2 Likes