Giter Site home page Giter Site logo

js-async-promises-lab-immersive-alum's Introduction

JS Async Promises Lab

Objectives

  1. Practice working with setTimeout and asynchronous code
  2. Practice working with promises

Introduction

In this lab we'll practice using promises, as well as our other JavaScript skills, to make a game that some of our passengers can play during their ride. It's a quiz game with a series of true or false question that our passengers must answer. The user clicks on the "Ask Away!" button and that displays the next question as well as the True and False buttons. If they guess correctly, their score increments. If within five seconds the user does not answer the question, time is up and the question, and True and False buttons, disappear while the "Ask Away button appears again".

Your task

We have already done some of the work for you. We have uploaded the "materialize.css" library, so that our game has some styling. And if you look at the index.html file, you can see that we have provided a div "question-container" where the question should be displayed, and a div of "true false list" to hold the buttons.

There are number of functions that we need to build to get this functionality to work.

  • nextQuestion - Updates the global question variable to the next question in the list or loops back around to the start from the end of the list.
  • appendQuestion - Appends the question to the "question-container" in the index.html file
  • askQuestionThen(time) - Returns a promise that is resolved after (1) the user selects an answer or (2) after a specified amount of time (so that we can expire the question after 5 seconds). The amount of time to wait is provided as an argument to the function. The resolve value should reflect whether the user successfully answered the question correctly.
  • removeQuestion() - Removes the question from the "question-container". It also hides the true and false buttons and shows the ask away button again.
  • askQuestionThenRemoveQuestion(time) - It appends the question to the "question-container" and after (1) the user selects an answer or (2) after a specified amount of time, removes the question. It takes an argument of "time" indicating the amount of time the question will be displayed.
  • toggleButtons - It toggles the hide class if not on the buttons, and removes the hide class if it is on the buttons. This should affect the true, false, and ask away buttons.
  • displayQuestionOnClick - It hides the ask away button while displaying the true and false buttons and the question for five seconds, and then hides both of the true and false questions, removes the text of the question, and shows the ask away button

Resources

js-async-promises-lab-immersive-alum's People

Contributors

jeffkatzy avatar thuyanduong-flatiron avatar gj avatar

Watchers

James Cloos 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.