Git Product home page Git Product logo

guesser's Introduction

Guesser

This is a simple game where you're given a letter and you have to guess its index number.

  • In Guesser.js, define a function called letterGuesser.
  • Inside your function, create an array of letters from "a" to "z" and save this array to a variable.
  • Using Math.random(), generate a random number between 0 and the length of your alphabet array. Save this number to a variable.
  • Use that random number as an index to select the correlating letter from your alphabet array.
  • Using string interpolation and prompt(), inform the user what letter they have received, ask the user to guess the letter's index number, and save that guess to a variable.
  • Make sure the guess's data type is a number!
  • Use conditional logic to check if the user's guess matches the actual index of the random letter. If it does, use alert() to tell them that they're a genius at the alphabet; if it doesn't match, tell them that they need to learn their ABCs and use string interpolation to give them the correct answer.
  • Call letter_guesser.
  • Save your work, go to the browser, and refresh to run the file you just created.

The result should look something like this:

Your letter is c. Guess c's index number.
2
You definitely know the alphabet!
Prompt: Your letter is z. Guess z's index number.
1
incorrect, you will have to re-learn the abc's. The index of z is actually 25.

guesser's People

Contributors

jonathanh7 avatar brandoturner avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.