I’m a totally newbie into coding. It’s hard but i love it! - I’m just started the “Number Guesser” project and i’m stuck at task number 3.
Here’s the task:
generateTarget() function. This function will be called at the start of each new round in order to generate the new secret target number.
***This function should return a random integer between
My answer so far is: const generateTarget(Math.floor(Math.random() * 10));
But i’m not sure that’s the right way to put it?
Furthermore task number 4 says:
compareGuesses() function. This function will be called each round to determine which guess is closest to the target number.
- Has three parameters representing the user (human) guess, a computer guess, and the secret target number to be guessed.
- Determines which player (human or computer) wins based on which guess is closest to the target. If both players are tied, the human user should win.
trueif the human player wins, and
falseif the computer player wins.
My question to you guys is how would you write the first block of code and why so?
My second question is how would you write the code block for task 4 and why?
Hope some of you got the time to help a fellow coder who’s completly blank at the moment!