01-02 Let's Practice Vocab
TOPIC: Start ボタンの処理
CHECK
questionAnswersContainerEl
, headerContainerEl
, headerSmallEl
を設定
currentQuestionIndex
変数の設定
startGame()
currentQuestionIndex
を 0 に初期化する
questionAnswersContainerEl
についている hide を消し、表示する
- スタート画面の Header を消す
- 小さな Header を画面上部に表示する
setNextQuestion()
を作る
console.log()
が表示されるかを確認
- 質問画面に移るかを確認
const startBtnEl = document.getElementById("start-btn")
const questionAnswersContainerEl = document.getElementById(
"question-answers-container"
)
const headerContainerEl = document.getElementById("header-container")
const headerSmallEl = document.getElementById("header-small")
let shuffledQuestions
let currentQuestionIndex
startBtnEl.addEventListener("click", startGame)
function startGame() {
startBtnEl.classList.add("hide")
shuffledQuestions = questions.sort(() => Math.random() - 0.5)
currentQuestionIndex = 0
questionAnswersContainerEl.classList.remove("hide")
headerContainerEl.style["display"] = "none"
headerSmallEl.classList.remove("hide")
setNextQuestion()
}
function setNextQuestion() {
console.log("NEXT QUESTION!!")
}
const questions = [
{
target_num: 1,
jp: "現代の科学技術は私たちの生活を大いに[向上させた]。",
en: "Modern technology has greatly ( ) our lives.",
answers: [
{
text: "considered",
correct: false,
},
{
text: "improved",
correct: true,
},
{
text: "concerned",
correct: false,
},
{
text: "included",
correct: false,
},
],
},
{
target_num: 2,
jp: "生活の質はエネルギー使用に直接[関連し]てはいない。",
en: "The quality of life is not directly ( ) to energy use.",
answers: [
{
text: "produced",
correct: false,
},
{
text: "related",
correct: true,
},
{
text: "provided",
correct: false,
},
{
text: "improved",
correct: false,
},
],
},
{
target_num: 3,
jp: "言語はすべて私たちに社会に関する貴重な情報を[与える]ことができる。",
en: "All languages can ( ) us with valuable information about society.",
answers: [
{
text: "provide",
correct: true,
},
{
text: "include",
correct: false,
},
{
text: "relate",
correct: false,
},
{
text: "concern",
correct: false,
},
],
},
]