Skip to content

Instantly share code, notes, and snippets.

@amgKM
amgKM / number-guesser.js
Last active September 29, 2021 00:07
Number Guesser Codecademy
let humanScore = 0;
let computerScore = 0;
let currentRoundNumber = 1;
// Generate the new secret target number
const generateTarget = () => Math.floor(Math.random() * 10);
// Calculate the distance from the computer guess to the target and from the human guess to the target
const getAbsoluteDistance = (num1, num2) => Math.abs(num1 - num2);