Half Module 2 project of the Adalab Digital Frontend Development Bootcamp.
This is an app to guess a random number developed with and
Project URL is available on GitHub Pages.
Instructions to start this project:
- Clone repository:
git clone [repository]
- Run project on local server with VSCode live server plugin.
- Generate a random number with methods Math.random and Math.ceil when app runs
- Input to enter a random number manually
- Button to send manual random number to app
- Inputs for clues and attemps to guess random number. Clues help user to find if manual random number matchs with generated random number
function getRandomNumber(max) {
return Math.ceil(Math.random() * max);
}
function getFinalNumber() {
const userNumber = parseInt(inputElement.value);
console.log(userNumber);
if (userNumber > 0 && userNumber <= 100) {
if (userNumber > randomNumber) {
clueElement.innerHTML = "Pista: demasiado alto";
} else if (userNumber < randomNumber) {
clueElement.innerHTML = "Pista: demasiado bajo";
} else if (userNumber === randomNumber) {
clueElement.innerHTML = "Has ganado campeona!!!";
}
} else {
clueElement.innerHTML = "Pista: el número debe estar entre 1 y 100";
}
attemptsElement.innerHTML = getAttemptsNumber();
}
function getAttemptsNumber() {
attempts++;
return `Número de intentos: ${attempts}`;
}
Random Number
├── images
│ └── app.png
├── styles
│ └── main.css
├── index.html
├── LICENSE
├── main.js
└── README.md