Giter Club home page Giter Club logo

quiz-application-assessment's Introduction

Quiz app using HTML, CSS, and Javascript from harjot singh for assessment

Arcitecture :

Index file | | | | game highscore

we create game.html and game.css.

  • Display Hard Coded Questions
  • Create game.js file
  • Create functions that load questions, identify selected answers

Need to figure out how to query each of the .choice-text elements, so using data-number="X". We then change that to an array using const choices = Array.from(document.getElementsByClassName("choice-text"));

JavaScript Spread syntax to bring the questions array into the availableQuestions array

Then I also uses the [splice] method which adds/removes items to/from an array.

Display Feedback for Correct/Incorrect Answers

  • Apply a class to the question element based on correct/incorrect answer selection
  • use setTimeout to display the correct/incorrect answer for 1000ms before calling getNewQuestion();
  • Add the HTML/CSS elements to create a header (Question and Score)
  • Created function to increment score if answer is correct.
  • Create a Progress Bar
  • The progress bar is filled in by adjusting the width of inner div using rogressBarFull.style.width = ${(questionCounter / MAX_QUESTIONS) * 100}%

At end I did :

  • Created end.html and end.js files
  • Added CSS for forms
  • Added function to end.js that checks for a value in the username field to disable to the save button

Score saving :

  • Save High Scores in Local Storage

  • Saves player's score to local storage localStorage.setItem("mostRecentScore", score);

  • Application tab > Local Storage

  • sort high scores, limit scores to top 5, and write them to local storage

  • Load and Display High Scores from Local Storage

  • Creates highscores.html, highscores.css, and highscores.js pages

  • Pulls in high scores from local storage using const highScores = JSON.parse(localStorage.getItem('highscores')) || [];

  • Use JS array map() to convert the returned array from local storage to elements for an HTML list

Fetch API to Load Local Questions:

  • Move hard coded questions from game.js to questions.json
  • questions from questions.json and display them in the console:

Fetch API to Load Questions API:

Uses Open Trivia DB API to pull questions. Side note: I installed JSON Formatter into Chrome to be able to view the returned JSON in a cleaner format.

The format in which questions are returned from Open Trivia DB is not the format we use in our app. So we're going to use a map function to clean it up.

This is end

quiz-application-assessment's People

Contributors

harjotcyber007 avatar

Stargazers

Roman 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.