-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
20 lines (18 loc) · 849 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
window.addEventListener("DOMContentLoaded", () => {
// Declaring startbutton and adding an event listener to start the game,
// fetch the API and hide the upper container.
let startButton = document.getElementById("button");
let topContainer = document.querySelector(".topContainer");
startButton.addEventListener("click", function(e) {
topContainer.classList.add("hide");
let numberOfQuestions = document.querySelector(".numberOfQuestions").value;
let APIkey = "KCL6vlHoXucS9J3xWehrJTI9Y3JX5zrcxhwPAGTG";
let url = `https://quizapi.io/api/v1/questions?apiKey=${APIkey}&category=code&difficulty=Easy&limit=${numberOfQuestions}&tags=JavaScript`;
fetch(url)
.then(response => response.json())
.then(data => {
let questions = new QuestionSet(data);
questions.addPlayer();
});
});
});