0% found this document useful (0 votes)
5 views

Cod

Uploaded by

chowdhryshipra7
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Cod

Uploaded by

chowdhryshipra7
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

<!

DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Grammenge</title>

<style>

body {

font-family: Arial, sans-serif;

background-color: #f0f0f0;

#game-container {

width: 80%;

margin: auto;

background-color: #fff;

padding: 20px;

border-radius: 5px;

box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);

#question {

font-size: 18px;

margin-bottom: 20px;

#options {

list-style-type: none;

padding: 0;

display: flex;

justify-content: space-between;

flex-wrap: wrap;

}
#options li {

background-color: #f5f5f5;

padding: 10px;

border-radius: 5px;

margin-bottom: 10px;

width: calc(33.33% - 10px);

#options li:hover {

cursor: pointer;

background-color: #e0e0e0;

#timer {

font-size: 16px;

font-weight: bold;

color: #ff0000;

margin-top: 20px;

#score {

font-size: 16px;

font-weight: bold;

color: #008000;

margin-top: 20px;

#result {

font-size: 16px;

font-weight: bold;

margin-top: 20px;

</style>

</head>
<body>

<div id="game-container">

<div id="question"></div>

<ul id="options"></ul>

<div id="timer"></div>

<div id="score"></div>

<div id="result"></div>

</div>

<script>

const questionEl = document.getElementById("question");

const optionsEl = document.getElementById("options");

const timerEl = document.getElementById("timer");

const scoreEl = document.getElementById("score");

const resultEl = document.getElementById("result");

let timeLeft = 60;

let score = 0;

let currentQuestion = 0;

const questions = [

text: "The cat is sitting on the mat.",

correct: "present tense",

options: ["present tense", "past tense", "future tense", "conditional tense"]

},

text: "She had already eaten when I arrived.",

correct: "past perfect",

options: ["past perfect", "past simple", "present perfect", "future perfect"]

},

text: "I will go to the store tomorrow.",

correct: "future tense",


options: ["future tense", "present tense", "past tense", "conditional tense"]

},

text: "He was here yesterday.",

correct: "past tense",

options: ["past tense", "present tense", "future tense", "conditional tense"]

},

text: "If I had a million dollars, I would buy a house.",

correct: "conditional tense",

options: ["conditional tense", "future tense", "present tense", "past tense"]

},

text: "He was standing by the door.",

correct: "past continuous",

options: ["past continuous", "past simple", "present continuous", "future continuous"]

},

text: "She has been to Paris twice.",

correct: "present perfect continuous",

options: ["present perfect continuous", "past perfect continuous", "future perfect continuous",
"present perfect"]

},

text: "They have been studying for hours.",

correct: "present perfect continuous",

options: ["present perfect continuous", "past perfect continuous", "future perfect continuous",
"present perfect"]

},

text: "I will have been working here for a year next month.",

correct: "future perfect continuous",

options: ["future perfect continuous", "future perfect", "present perfect continuous", "past perfect
continuous"]

},
{

text: "He had been waiting for hours.",

correct: "past perfect continuous",

options: ["past perfect continuous", "past perfect", "present perfect continuous", "future perfect
continuous"]

},

text: "The book is on the table.",

correct: "preposition",

options: ["preposition", "verb", "tense", "model"]

},

text: "He sings very well.",

correct: "verb",

options: ["preposition", "verb", "tense", "model"]

},

text: "The cat is sitting on the mat.",

correct: "model",

options: ["preposition", "verb", "tense", "model"]

},

text: "I am going to the store.",

correct: "model",

options: ["preposition", "verb", "tense", "model"]

},

text: "She is a teacher.",

correct: "model",

options: ["preposition", "verb", "tense", "model"]

},

text: "He was working yesterday.",

correct: "model",
options: ["preposition", "verb", "tense", "model"]

},

text: "The cat is sleeping under the bed.",

correct: "model",

options: ["preposition", "verb", "tense", "model"]

},

text: "They are playing soccer in the park.",

correct: "model",

options: ["preposition", "verb", "tense", "model"]

},

text: "She is cooking dinner for us.",

correct: "model",

options: ["preposition", "verb", "tense", "model"]

},

text: "He is writing a letter.",

correct: "model",

options: ["preposition", "verb", "tense", "model"]

];

function startGame() {

timerEl.textContent = `Time left: ${timeLeft}`;

scoreEl.textContent = `Score: ${score}`;

nextQuestion();

function nextQuestion() {

if (currentQuestion >= questions.length) {

resultEl.textContent = `Bravo! Your final score is: ${score}`;

return;
}

questionEl.textContent = questions[currentQuestion].text;

optionsEl.innerHTML = "";

questions[currentQuestion].options.forEach((option, index) => {

const li = document.createElement("li");

li.textContent = option;

li.onclick = () => checkAnswer(option, index);

optionsEl.appendChild(li);

});

function checkAnswer(answer, index) {

if (answer === questions[currentQuestion].correct) {

score++;

scoreEl.textContent = `Score: ${score}`;

currentQuestion++;

if (currentQuestion < questions.length) {

setTimeout(() => nextQuestion(), 1000);

} else {

resultEl.textContent = `Bravo! Your final score is: ${score}`;

function countdown() {

timeLeft--;

timerEl.textContent = `Time left: ${timeLeft}`;

if (timeLeft === 0) {

resultEl.textContent = `Game over! You ran out of time. Your final score is: ${score}`;

} else {

setTimeout(countdown, 1000);

}
startGame();

countdown();

</script>

</body>

</html>

You might also like