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');
}
});
});