Passing Values to Functions with Arguments (negative)

Passing Values to Functions with Arguments (negative)
0.0 0


Hello everyone, I was playing around with arguments on this challenge and I got strange result when passing negative -1 and positive 1. On freecodecamp the rusult is 5. Tried same code on my phone and got 0 as it should be.

The difference works not as I expected also: functionWithArgs(1, -1) with console.log(x -y) results in 2, which is TRUE; (-1, 1) => -2, also TRUE; but (-1, -1) => 5;

What’s the catch here? Thanks.

function functionWithArgs(x, y) {
  console.log(x + y);
functionWithArgs(1, -1);


I’m not really sure what you’re talking about. My best guess is that the 5 you’re seeing results from FCC running one of its own tests.

Here is your function running with variations on 1 and -1:


Thank you for the lightning fast response, I thought I made a mistake when passing the negative number in, now I understood!