Quiz App in JavaScript

Create a quiz application

IntermediateMini ProjectsExample 5 of 20
quiz-app.js
1class Quiz {
2 constructor(questions) { this.questions = questions; this.score = 0; this.current = 0; }
3 answer(answer) { if(answer === this.questions[this.current].correct) this.score++; this.current++; }
4 isComplete() { return this.current >= this.questions.length; }
5 getScore() { return this.score; }
6}

Output

// Quiz functionality

What's going on

Quiz App manages quiz questions and scoring.