Skip to content

anaguerraabaroa/random-number

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Random Number App

Random Number

About

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.

Quick start guide

Instructions to start this project:

Installation

  • Clone repository:
git clone [repository]
  • Run project on local server with VSCode live server plugin.

Features

  • 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

Usage

Get random number

function getRandomNumber(max) {
  return Math.ceil(Math.random() * max);
}

App handler

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();
}

Get attempts to guess number

function getAttemptsNumber() {
  attempts++;
  return `Número de intentos: ${attempts}`;
}

Folder Structure

Random Number
├── images
│   └── app.png
├── styles
│   └── main.css
├── index.html
├── LICENSE
├── main.js
└── README.md

License

This project is licensed under GitHub

About

📱 👩 💻 Random Number APP || Developed with HTML5, CSS3 and JavaScript || Half Module 2 Project of the Adalab Digital Frontend Development Bootcamp

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published