How to check the answer in a quiz?
-
I have made a sortable list to rearrange the words to make a meaningful sentence. I am unable to figure out why the alert in checking the answer section is not working. This is not working: alert('success');
$(document).ready(function () {
var words = [];
var i = 0;
function showWords() {
$('#container').append("");
for (var j = 0; j < words[i].question.length; j++) {
$('#list').append("* " + words[i].question[j] + " " + "
");
}$('#list').sortable({ placeholder: 'back', axis: 'x', opacity: '0.7' });
}
showWords();$(document).on('click', '#btn', function () {
var guess = $('.box').text();
$('#list').empty();
if (i < words.length); {
var correct = words[i].answer;
i++;
showWords();
}
if (guess === correct) {
alert('success');
}
});
}); -
I have made a sortable list to rearrange the words to make a meaningful sentence. I am unable to figure out why the alert in checking the answer section is not working. This is not working: alert('success');
$(document).ready(function () {
var words = [];
var i = 0;
function showWords() {
$('#container').append("");
for (var j = 0; j < words[i].question.length; j++) {
$('#list').append("* " + words[i].question[j] + " " + "
");
}$('#list').sortable({ placeholder: 'back', axis: 'x', opacity: '0.7' });
}
showWords();$(document).on('click', '#btn', function () {
var guess = $('.box').text();
$('#list').empty();
if (i < words.length); {
var correct = words[i].answer;
i++;
showWords();
}
if (guess === correct) {
alert('success');
}
});
});Welcome, you've posted your question in the wrong area. Look above at the red text, there's a link that will take you to an area where you can ask your question.
Give me coffee to change the things I can and wine to accept the things I cannot! JaxCoder.com
-
Welcome, you've posted your question in the wrong area. Look above at the red text, there's a link that will take you to an area where you can ask your question.
Give me coffee to change the things I can and wine to accept the things I cannot! JaxCoder.com
-
I have made a sortable list to rearrange the words to make a meaningful sentence. I am unable to figure out why the alert in checking the answer section is not working. This is not working: alert('success');
$(document).ready(function () {
var words = [];
var i = 0;
function showWords() {
$('#container').append("");
for (var j = 0; j < words[i].question.length; j++) {
$('#list').append("* " + words[i].question[j] + " " + "
");
}$('#list').sortable({ placeholder: 'back', axis: 'x', opacity: '0.7' });
}
showWords();$(document).on('click', '#btn', function () {
var guess = $('.box').text();
$('#list').empty();
if (i < words.length); {
var correct = words[i].answer;
i++;
showWords();
}
if (guess === correct) {
alert('success');
}
});
});visit stackoverflow.com sign up for an account post question wait answer profit!!!
Caveat Emptor. "Progress doesn't come from early risers – progress is made by lazy men looking for easier ways to do things." Lazarus Long
-
visit stackoverflow.com sign up for an account post question wait answer profit!!!
Caveat Emptor. "Progress doesn't come from early risers – progress is made by lazy men looking for easier ways to do things." Lazarus Long
abmv wrote:
visit stackoverflow.com
I can't believe you're recommending the competition here. If only there were somewhere on CP for people to ask questions.
This space for rent
-
visit stackoverflow.com sign up for an account post question wait answer profit!!!
Caveat Emptor. "Progress doesn't come from early risers – progress is made by lazy men looking for easier ways to do things." Lazarus Long
Which Ferengi rule of acquisition is that? ;)
Latest Article - A 4-Stack rPI Cluster with WiFi-Ethernet Bridging Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
-
I have made a sortable list to rearrange the words to make a meaningful sentence. I am unable to figure out why the alert in checking the answer section is not working. This is not working: alert('success');
$(document).ready(function () {
var words = [];
var i = 0;
function showWords() {
$('#container').append("");
for (var j = 0; j < words[i].question.length; j++) {
$('#list').append("* " + words[i].question[j] + " " + "
");
}$('#list').sortable({ placeholder: 'back', axis: 'x', opacity: '0.7' });
}
showWords();$(document).on('click', '#btn', function () {
var guess = $('.box').text();
$('#list').empty();
if (i < words.length); {
var correct = words[i].answer;
i++;
showWords();
}
if (guess === correct) {
alert('success');
}
});
});Since you already have the words, just arrange them yourself - it'll should be no problem at all, once you get rid of those "{" and "}" that are just confusing the issue.
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein
"If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010
-
abmv wrote:
visit stackoverflow.com
I can't believe you're recommending the competition here. If only there were somewhere on CP for people to ask questions.
This space for rent
Pete O'Hanlon wrote:
If only there were somewhere on CP for people to ask questions.
If only good people with the best technical minds on CP, like Pete, and Marc, answered questions in somewhere on CP for people to ask questions :)
«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot