diff --git a/src/main.js b/src/main.js
index 220b44a..42ed6ba 100644
--- a/src/main.js
+++ b/src/main.js
@@ -1,5 +1,6 @@
import './style.css';
import Button from './components/Button.js';
+import Question from './model/question.js';
document.querySelector('#app').innerHTML = `
CC first project
@@ -9,6 +10,20 @@ const simpleCallback = () => {
console.log(`Greetings from koala`);
};
+// how to use Question class Question has {imageUrl, correct, incorrectAnswers, question} and .getAnswers method
+
+const firstQuestion = new Question(
+ 'url',
+ 'Ala',
+ ['Ula', 'Ela', 'Ola'],
+ "Mirror, mirror on the wall who's the fairest of them all?",
+);
+
+console.log(firstQuestion.question);
+console.log(firstQuestion.getAnswers());
+console.log('The correct answer is:');
+setTimeout(() => console.log(firstQuestion.correct), 3000);
+
// how to use: Button(label, className, animate, 'eventListener', callback)
const buttonQuiz = Button('start quiz', 'quiz', true, 'click', simpleCallback);
const buttonLeaderboard = Button('leaderboard', 'leaderboard', true, 'click', simpleCallback);
diff --git a/src/model/question.js b/src/model/question.js
new file mode 100644
index 0000000..507a7c9
--- /dev/null
+++ b/src/model/question.js
@@ -0,0 +1,14 @@
+export default class Question {
+ constructor(imageUrl, correct, incorrectAnswers, question) {
+ this.imageUrl = imageUrl;
+ this.correct = correct;
+ this.incorrectAnswers = incorrectAnswers;
+ this.question = question;
+ }
+
+ getAnswers() {
+ const answers = [this.correct, ...this.incorrectAnswers];
+ answers.sort(() => (Math.random() > 0.5 ? 1 : -1));
+ return answers;
+ }
+}