Calculator Tools Calculator Tools
Create

The Beatles Lyrics Quiz

Jan 10, 2024

About this app

Test your knowledge of The Beatles lyrics with this fun quiz!

The Beatles Lyrics Quiz The Beatles Lyrics Quiz Next

Related apps

Put this on your site

Source

                    <html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">

<title>The Beatles Lyrics Quiz</title>
<meta name="description" content="Test your knowledge of The Beatles lyrics with this fun quiz!">
<meta name="keywords" content="The Beatles, lyrics, quiz">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">

<script type="text/javascript">
try {
// App Javascript Goes Here. Place your entire script content inside the try block for error handling.
const quizQuestions = [
{
question: "Which song contains the lyrics: 'I get high with a little help from my friends'?",
options: ["Hey Jude", "Eleanor Rigby", "With a Little Help from My Friends", "Let It Be"],
answer: "With a Little Help from My Friends"
},
{
question: "Which song contains the lyrics: 'Yellow matter custard, dripping from a dead dog's eye'?",
options: ["I Want to Hold Your Hand", "Strawberry Fields Forever", "Lucy in the Sky with Diamonds", "A Hard Day's Night"],
answer: "Lucy in the Sky with Diamonds"
},
{
question: "Which song contains the lyrics: 'Yesterday, all my troubles seemed so far away'?",
options: ["Yesterday", "Here Comes the Sun", "Blackbird", "Twist and Shout"],
answer: "Yesterday"
},
{
question: "Which song contains the lyrics: 'I am he as you are he as you are me and we are all together'?",
options: ["I Am the Walrus", "Penny Lane", "Ticket to Ride", "Help!"],
answer: "I Am the Walrus"
},
{
question: "Which song contains the lyrics: 'Hey Jude, don't make it bad'?",
options: ["Hey Jude", "Strawberry Fields Forever", "Let It Be", "Yellow Submarine"],
answer: "Hey Jude"
},
{
question: "Which song contains the lyrics: 'Here comes the sun, and I say It's all right'?",
options: ["Here Comes the Sun", "All You Need Is Love", "Hello, Goodbye", "The Long and Winding Road"],
answer: "Here Comes the Sun"
},
{
question: "Which song contains the lyrics: 'Blackbird singing in the dead of night'?",
options: ["Blackbird", "Penny Lane", "A Hard Day's Night", "Twist and Shout"],
answer: "Blackbird"
},
{
question: "Which song contains the lyrics: 'She's got a ticket to ride'?",
options: ["Let It Be", "Ticket to Ride", "Eleanor Rigby", "I Want to Hold Your Hand"],
answer: "Ticket to Ride"
},
{
question: "Which song contains the lyrics: 'All you need is love, love, love is all you need'?",
options: ["All You Need Is Love", "Yesterday", "Help!", "Hey Jude"],
answer: "All You Need Is Love"
},
{
question: "Which song contains the lyrics: 'You say goodbye, and I say hello'?",
options: ["Hello, Goodbye", "Strawberry Fields Forever", "I Am the Walrus", "Yellow Submarine"],
answer: "Hello, Goodbye"
}
];

let currentQuestion = 0;
let score = 0;

function showQuestion() {
const questionElement = document.getElementById("question");
const optionsElement = document.getElementById("options");
const nextButton = document.getElementById("next");

questionElement.textContent = quizQuestions[currentQuestion].question;
optionsElement.innerHTML = "";

quizQuestions[currentQuestion].options.forEach((option) => {
const optionElement = document.createElement("button");
optionElement.className = "btn btn-primary";
optionElement.textContent = option;
optionElement.addEventListener("click", selectOption);
optionsElement.appendChild(optionElement);
});

nextButton.style.display = "none";
}

function selectOption(event) {
const selectedOption = event.target.textContent;
const correctAnswer = quizQuestions[currentQuestion].answer;
const resultElement = document.getElementById("result");
const nextButton = document.getElementById("next");

if (selectedOption === correctAnswer) {
score++;
resultElement.innerHTML = "<i class='fa fa-check'></i> Correct!";
resultElement.classList.add("text-success");
} else {
resultElement.innerHTML = "<i class='fa fa-times'></i> Incorrect!";
resultElement.classList.add("text-danger");
}

nextButton.style.display = "block";
nextButton.addEventListener("click", nextQuestion);
}

function nextQuestion() {
const resultElement = document.getElementById("result");
const nextButton = document.getElementById("next");

resultElement.textContent = "";
resultElement.classList.remove("text-success", "text-danger");

currentQuestion++;

if (currentQuestion === quizQuestions.length) {
showResult();
} else {
showQuestion();
}

nextButton.style.display = "none";
}

function showResult() {
const quizContainer = document.getElementById("quiz-container");
const resultContainer = document.getElementById("result-container");
const scoreElement = document.getElementById("score");

quizContainer.style.display = "none";
resultContainer.style.display = "block";

scoreElement.textContent = `You scored ${score} out of ${quizQuestions.length}!`;
}

// This will run when the DOM is ready.
document.addEventListener("DOMContentLoaded", function() {
showQuestion();
});

} catch (error) {
// This will throw the error to the parent window.
throw error;
}
</script>

<style>
body {
background-color: #f6f8fa;
font-family: 'Roboto', sans-serif;
}

.container {
max-width: 600px;
margin: 0 auto;
padding: 20px;
}

h1 {
text-align: center;
margin-bottom: 30px;
}

.btn-primary {
width: 100%;
margin-bottom: 10px;
}

.text-success {
color: #28a745;
}

.text-danger {
color: #dc3545;
}

#result-container {
display: none;
}

#result {
margin-bottom: 20px;
text-align: center;
font-size: 18px;
}

</style>
</head>
<body>
<div id="main-container" class="container">
<h1>The Beatles Lyrics Quiz</h1>
<div id="quiz-container">
<p id="question"></p>
<div id="options"></div>
<p id="result"></p>
<button id="next" class="btn btn-primary">Next</button>
</div>
<div id="result-container">
<p id="score"></p>
</div>
</div>
</body>
</html>