GithubHelp home page GithubHelp logo

rileyhawk1417 / quizgamejs Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 559 KB

Game built using JavaScript, Sass and HTML

Home Page: https://rileyhawk1417.github.io/quizGameJS/

CSS 0.36% JavaScript 43.20% SCSS 40.51% HTML 15.93%

quizgamejs's Introduction

Quiz Game

Description ๐Ÿ“”

The game is entirely built using Vanilla JavaScript without using any frameworks. I would consider it good practice to enhance your skills. The game uses Local Storage to keep the previous score entered by the user local storage. Local storage uses a key:value system so the value is overwritten every time a new score is entered. You can test the game out here : Link on GitHub Pages ๐Ÿ”—

Please Note

  • Some of the codes in the README.md are just pieces I picked out to explain which parts of the code work. The actual code is a bit confusing but there are some comments that will help. Overtime will be refactoring and experimenting trying to add new feature/functions. ๐Ÿ˜

Keep it Simple ๐Ÿ˜Ž


How it works โš™๏ธ

  • The project needs to be running on a local host server or live server. It wont run the scripts if you are running the files directly.
  • When you open geometry HTML it then welcomes you and offers to view the HighScore or to play the game.
  • The game itself has a timer that will automatically end the game if the user fails to answer within that time set. They will still have their score stored either way.
  • After the game they will have to enter their HighScore to save their name.
  • Please note that the game can only save one name at a time since it uses local storage.

Code Structure ๐Ÿ“‹

  • The code will run a loop to display all answers for the user to select.
    question.ans.forEach((answer) => {
        const button = document.createElement('button');
        button.innerText = answer.choice;
        button.classList.add('ans');
        if(answer.correct){
            button.dataset.correct = answer.correct;
        }
        button.addEventListener('click', choiceSelect);
        answerBox.appendChild(button);
  • When the user selects a answer there is an event listener that will determine if he answer box matches with the conditionals in questions.js
  • When the game ends the game will take the user to the HighScore Screen to submit their name. The name and score gets saved to local storage.
let getScore = localStorage.getItem('recentScore');

    const score={
         userScore: getScore,
         name: userName
     }
     highScore.push(score);

localStorage.setItem('highScore', JSON.stringify(highScore));

quizgamejs's People

Contributors

rileyhawk1417 avatar

Watchers

 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.