Hi, hope you’re all ok
I’m new to coding and if you could help it will mean a lot.
Inumer guesser project
Code is working (not showing any errors)… BUT
-
When it increment rounds by one… from round no. 1 it goes straight to round no.3 ? Later it works fine and counting rounds as it should.
-
It adds points only to human player… It shows that computer Wins but scores still going to human.
Thank you for your help!
let humanScore = 0;
let computerScore = 0;
let currentRoundNumber = 1;
// Write your code below:
const generateTarget = (you) =>{
return Math.floor(Math.random()*10); // step 3
};
const compareGuesses = (human,computer,target) => { //step 4
const computerD = Math.abs(target - computer);
const humanD = Math.abs(target - human);
if (humanD === computerD){
return true;
}
else if (humanD < computerD){
return true;
} else if(humanD > computerD){
return false;
}else { return 'Error'}
};
const updateScore = (winner) => {
winner ? humanScore++ : computerScore++;
};
advanceRound = () =>{
currentRoundNumber++
};
advanceRound();