Last active
March 16, 2018 11:39
-
-
Save samueljoli/98bb0c9f9070659ec820d86574652dad to your computer and use it in GitHub Desktop.
Exported from Popcode. Click to import: https://popcode.org/?gist=98bb0c9f9070659ec820d86574652dad
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Page Title</title> | |
</head> | |
<body> | |
<h1>Trivia!!</h1> | |
<div id='questions'> | |
<p id='question'></p> | |
<p id='result'></p> | |
</div> | |
<button id='yes'>Yes</button> | |
<button id='no'>No</button> | |
<button id='next'>Next</button> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"enabledLibraries":["jquery"],"hiddenUIComponents":["editor.css","editor.html","console","editor.javascript"]} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var questionOne = 'Goku is the GOAT'; | |
var answerOne = 'Yes'; | |
var questionTwo = 'Yamcha is the GOAT'; | |
var answerTwo = 'No'; | |
var questions = [ | |
questionOne, | |
questionTwo | |
]; | |
var answers = [ | |
answerOne, | |
answerTwo | |
]; | |
var index = 0; | |
$('#question').text(questions[index]); | |
$('#yes').click(function(){ | |
var response = $(this).text(); | |
var answer = answers[index]; | |
if(response === answer) { | |
$('#result').text('Correct'); | |
} | |
else { | |
$('#result').text('Wrong'); | |
} | |
}); | |
$('#no').click(function(){ | |
var response = $(this).text(); | |
var answer = answers[index]; | |
console.log(response, answer); | |
if(response === answer) { | |
$('#result').text('Correct'); | |
} | |
else { | |
$('#result').text('Wrong'); | |
} | |
}); | |
$('#next').click(function(){ | |
++index; | |
$('#result').text(''); | |
$('#question').text(questions[index]); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment