Number Guesser

I don/t get why computer wins always, can you guys give me a little help?

Number Guesser-----> link:

Hello Javier,
how do you call your function

const compareGuesses=(x,y,z)=>{
  var z=generateTarget();
  Math.abs(z-x) <= Math.abs(z-y)?true:false;

I’m a little astonished, that you get a result at all, because you don’t return anything from that function, neither do you assign a value to a variable.
What arguments do the parameters x, y, z receive?

how did i forgot it? (now i feel veryy stupid (-_-) )
fixed code:
thanks for taking your time

I see that you are returning a value from the function compareGuesses now, but I’m still missing the function call. What do the parameters x and y stand for?
The function generateTarget doesn’t make much sense in this context as you’re just returning a variable which you have assigned (but never declared) outside the function scope.

yeap i removed unnecessary function…
x and y are user and computer generated inputs which exercise declares itself after running it

it dont works without ‘generateTarget’, i guess exercice uses it for checking

I would need all the code to help. Or does your program run as expected now?

1 Like

it runs as expected…
and thanks again for taking your time and helping me out :innocent:

1 Like

You’re welcome. Happy coding! :slightly_smiling_face: