Created
August 18, 2016 22:57
-
-
Save ninabreznik/1c20aec88bf8bee1e633c5110098de9f to your computer and use it in GitHub Desktop.
Quiz002
This file contains 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
/*----------------------------------------------------- | |
ADD LOADING DATA | |
-------------------------------------------------------*/ | |
/*----------------------------------------------------- | |
UPDATE TEMPLATE FUNCTION | |
-------------------------------------------------------*/ | |
<div class="${css.question}"> | |
${question} | |
</div> | |
/*----------------------------------------------------------------------------- | |
LOADING DATA | |
-----------------------------------------------------------------------------*/ | |
var questions = [ | |
` | |
Statement #1: | |
The next social network I build, | |
will definitely be for cats. | |
`, | |
` | |
Statement #2: | |
I believe dogs should be allowed | |
everywhere people are | |
`, | |
` | |
Statement #3: | |
My friends say, my middle name should be "Meow". | |
`, | |
` | |
Statement #4: | |
Snoop Dog is definitely one of my | |
favourite artists | |
`, | |
` | |
Statement #5: | |
I think I could spend all day just | |
watching cat videows | |
`, | |
` | |
Statement #6: | |
I regularly stop people in the street | |
to pet their dogs. | |
` | |
] | |
var i = 0 | |
var question = questions[i] | |
var results = [] | |
var answerOptions = [1,2,3,4,5,6] | |
/*----------------------------------------------------- | |
ADD EVENT LISTENER onclick | |
-------------------------------------------------------*/ | |
<div class="${css.answers}"> | |
${answerOptions.map(x=>yo`<div class="${css.answer}" onclick=${nextQuestion(x)}>${x}</div>`)} | |
</div> | |
/*----------------------------------------------------- | |
ADD FUNCTION nextQuestion | |
-------------------------------------------------------*/ | |
function nextQuestion(id) { | |
return function () { | |
if (i < (questions.length-1)) { | |
results[i] = id | |
i = i+1 | |
question = questions[i] | |
yo.update(element, template()) | |
} else { | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment