Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>this is how i made it :) im verry happy i did it, i just saw @cmallard example and it seems i still need to improve some things, also seems that im in the correct way...if yo guys have any suggestions i would like to see them! :)</p> <pre><code>$(document).on('ready', ready); function ready(){ var allQuestions = [ { question: "Whats my real name?", choices: ["Jhonnatan", "Alberto", "Tatan","Jaime"], answer: 0 }, { question: "Who is Colombia's president?", choices: ["Alvaro Uribe", "Andres Pastrana", "Juan Manuel Santos","Tatan"], answer: 2 }, { question: "My favorite super heroe?", choices: ["Batman", "Flash", "Tatan","Javascript"], answer: 3 }, { question: "Wich sports do i practice?", choices: ["Climbing", "Swimming", "Programming","Running"], answer: 0 }, { question: "Whats my dad's name?", choices: ["Alberto", "Jorge", "Javier","Jose"], answer: 1 }, { question: "Whats my favorite color?", choices: ["Red", "Purple", "Blue","All"], answer: 2 }, { question: "My favorite alcoholic drink", choices: ["Vodka", "Aguardiente", "Rum","Tekila"], answer: 3 }, { question: "Whats my favorite kind of music?", choices: ["Hardcore", "Reggaeton", "Salsa","Programming"], answer: 0 }, { question: "How many qestions has this quiz??", choices: ["20", "8", "10","12"], answer: 2 }, { question: "My favorite programming lenguage?", choices: ["Ruby", "Arduino", "Python","Javascript"], answer: 3 } ]; var number=0; var question = $('#question'); var choice1 = $('#answer0'); var choice2 = $('#answer1'); var choice3 = $('#answer2'); var choice4 = $('#answer3'); var next = $('#next'); var currentQuestion = $('#current-question'); next.on('click', changeQuestion); addQuestionAndAnswers(); function addQuestionAndAnswers() { currentQuestion.text(number + 1); question.text(allQuestions[number].question); choice1.text(allQuestions[number].choices[0]); choice2.text(allQuestions[number].choices[1]); choice3.text(allQuestions[number].choices[2]); choice4.text(allQuestions[number].choices[3]); console.log('funcionando!'); } function changeQuestion(){ if(number!=9){ if($("#myForm input[type='radio']:checked").val() == allQuestions[number].answer){ number = number +1; addQuestionAndAnswers(); } else{ console.log('respuesta errada'); } } else { displayResult(); } function displayResult(){ currentQuestion.text('10'); $('#myForm').css('display', 'none'); $('#question').css('display', 'none'); $('#next').css('display', 'none'); $('#score').css('display', 'inline-block') $('#score').text('Your score is: ' + (number + 1) + 'pts'); } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload