Free JavaScript course. Sign Up for tracking progress →

JavaScript: How do we verify your solutions?

Our website verifies your solutions automatically. You may be wondering how it works.

In the most basic case, the system just runs your code and examines the output. Then it compares the actual output against the expected one.

The following lessons deal with more complex matters. You will be writing functions. They're like mini-programs that take data from outside and perform operations on it. Verifying solutions gets a little more complicated in this case. The system runs your code and passes data to it. The system knows what result a correctly written function would give with the data the system provides it with, and this result is what the system is "expecting".

Let's assume your task is to program a function that adds two numbers. The verification system will give it several combinations of numbers and compare your function's answers with the correctly calculated ones. If all actual values match the expected ones, your solution would be considered valid.

This is testing. It's used extensively in the real, day-to-day development process. Developers usually write the tests first, that will proceed to write the program itself. During that process, they run tests multiple times to check how close they are to the desired solution.

That is why our website says “Tests passed” once you solve the task correctly.

One of your tasks in the following lessons will be to write a function that performs certain calculations and returns the result. As an example, let's assume you made a small mistake and the function returns the wrong value. In that case, the system will give you the following message:

  ● test

  expect(received).toBe(expected) // equality

  Expected value to be:
    "Hello, World!"
    "ello, World!"

In addition to our tests, it's very useful to experiment with code in the browser console. When something isn't clear to you or you want to experiment with code, feel free to do all of this in the console. Ideally, it's best to execute all the code given in the lessons on your own. In addition to the console, you can also use

Sometimes when creating a solution, it may seem that you have done everything correctly, but the system has got into a huff and won't accept your solution. Such cases are borderline impossible. Failed tests simply won't get as far as the site, they are automatically run after each change. In the vast majority of cases (all our projects have been run millions of times in total over many years) the error is in the solution code. It can be very imperceptible, maybe you used the wrong punctuation, or you used upper case instead of lower case, or you missed a comma. Other cases are more complicated. Maybe your solution works for one set of inputs, but not for another. So always read the instructions and test your output carefully. There will almost certainly be some sign of an error.

However, if you are sure about a mistake or have found an inaccuracy, you can always point it out. At the end of each theory section, there is a link to the contents of the lesson on Github (this project is completely open-source!). You can write about an issue, look through the tests (you can see how your code is called there), and even send a pull request. If it's all gone over your head, then join the #hexlet-feedback channel in Slack community, where we'll always be ready to help you.


Print the following number: 9780262531962.
Experiment with the output. Try another number or string there. Look at the system's output.

The exercise doesn't pass checking. What to do? 😶

If you've reached a deadlock it's time to ask your question in the «Discussions». How ask a question correctly:

  • Be sure to attach the test output, without it it's almost impossible to figure out what went wrong, even if you show your code. It's complicated for developers to execute code in their heads, but having a mistake before their eyes most probably will be helpful.
In my environment the code works, but not here 🤨

Tests are designed so that they test the solution in different ways and against different data. Often the solution works with one kind of input data but doesn't work with others. Check the «Tests» tab to figure this out, you can find hints at the error output.

My code is different from the teacher's one 🤔

It's fine. 🙆 One task in programming can be solved in many different ways. If your code passed all tests, it complies with the task conditions.

In some rare cases, the solution may be adjusted to the tests, but this can be seen immediately.

I've read the lessons but nothing is clear 🙄

It's hard to make educational materials that will suit everyone. We do our best but there is always something to improve. If you see a material that is not clear to you, describe the problem in “Discussions”. It will be great if you'll write unclear points in the question form. Usually, we need a few days for corrections.

By the way, you can participate in courses improvement. There is a link below to the lessons course code which you can edit right in your browser.



  • Tests are special bits of code that validate programs by checking the correct result against the actual one.

If you got stuck and don't know what to do, you can ask a question in our community