Hello. I’m a total beginner in Javascript. My code works fine when I test it on different online compiler, but it always fails Test 3. The error mentions that “uses the passed in current time,” and the expected output is 2000 while mine is 2025.
Can you show us the full error message in a codeblock for this? It sounds like it’s for a different task so it’d be useful to see all your code as well.
OK, I found multiple issues here - with the tests and the OPs code.
First of all, the failing test is test 3 uses the passed in current time of task 1 (not Task 3). The result is shown in the Online editor as:
Code Run
expect(received).toEqual(expected) // deep equality
Test Failure
Expected: 2000
Received: 2025
That’s issue 2: Not a very helpful code snippet. What are the inputs? What method is actually called how?
Then, issue 3, as things are no longer executed in Exercisms infrastructure but the local Browser, there are many hard to understand timezone problems. I had to use getUTCDate() / setUTCDate() to make the OPs code actually get to where the OP received the initially posted test failure.
Last issue with the tests: The tests name uses the passed in current time is misleading: It passes in a UNIX timestamp far in the past, not a current time. Together with not seeing the inputs, it is impossible to understand that the current year (2025 as the OP got it in the failure message) is actually the wrong one, not 2000.
The issue making the OPs code fail at test 3 is rather “as expected”. The type checking of the input now does not work as the OP wanted it to work in createAppointment(). So for test 3 the initial Date object is made without using argument now.