repl.it
@anonymous/

AdoredVioletMaintenance

Nodejs

No description

fork
loading
Files
  • index.js
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
let humanScore = 0;
let computerScore = 0;
let currentRoundNumber = 1;

// Write your code below:

const genertateTarget = () => {Math.floor(Math.random() * 10)};


const compareGuesses = (humanGuess, computerGuess, secretTarget) => {
if (Math.abs(humanGuess - secterTarget) <= Math.abs(computerGuess - secretTarget)){
  return true;
} else if (Math.abs(humanGuess - secterTarget) > Math.abs(computerGuess - secretTarget)){
  return false;
}
}
const updateScore = (winner) => {
if (winner === 'human') {humanScore ++} else if (winner === 'computer') {computerScore++}
};

function advanceRound(){currentRoundNumber += 1}


// trying out your function
console.log(
  compareGuesses(5, 3, 10)
)