Welcome to the Get Help category!
This is where you can ask questions about your code. Some important things to remember when posting in this category
-
Learn how to ask a good question and get a good answer!
-
Remember to include a link to the exercise you need help with!
-
If someone answers your question, please mark their response as a solution
-
Once you understand a new concept, come back and try to help someone else!
let humanScore = 0;
let computerScore = 0;
let currentRoundNumber = 1;
// Write your code below:
const generateTarget = function(){
return Math.floor(Math.random()*9);
}
const compareGuess = function (humanGuess, computerGuess,targetGuess){
if((Math.abs( humanGuess - targetGuess )) < (Math.abs(computerGuess - targetGuess))){
return true;
}
else if ((Math.abs( humanGuess - targetGuess )) > (Math.abs(computerGuess - targetGuess)))
return false;
else if((Math.abs( humanGuess - targetGuess )) === (Math.abs(computerGuess - targetGuess))){
return true;
}
else{
return invalid;
}
}
const updateScore = function(){
if(compareGuess){
humanScore += 1
}
else if(compareGuess === false){
computerScore += 1
}
currentRoundNumber += 1
}
updateScore(‘human’);
console.log(humanScore); // To confirm that this value increased by 1
updateScore(‘computer’);
console.log(computerScore); // To confirm that this value increased by 1
This is my code and i can’t pass task 7. Can you help me please thanks again.