This is the starter package for FHS students to learn about ES6 modules.
- node
- npm
git clone git@github.com:webpapaya/fhs-modules.git
npm ci
npm run start
- We'll be building a quiz application
- This assignment includes the game logic only (no ui)
- define and export a list of questions from
questions.js
- a question looks like this:
{ question: 'some question', correctAnswer: 'a', a: 'answer', b: '', c: '', d: '' }
- a question looks like this:
- implement a function
askQuestion()
inquiz.js
- this function returns a random question (without the correctAnswer property)
- implement a function
answerQuestion(question, answer)
inquiz.js
- this function returns true or false depending on the given answer
- example usage:
// index.js
import { askQuestion, answerQuestion } from './quiz.js'
const question = askQuestion()
console.log(question)
/**
* {
* question: 'Whats the best university?',
* a: 'Hagenberg',
* b: 'FHS',
* c: 'TU',
* d: 'JKU'
* }
*/
const answer = answerQuestion(question, 'a')
console.log(answer ? 'correct' : 'incorrect')