I am fairly new to the JavaScript and JQuery world so the structure of my code is still getting there. I understand that there are methods of writing it so that it puts less strain on performance and thus makes your program work faster.
I have looked at various ways to achieve this but can't see how to apply it to what I have. I am looking to stack overflow to help show me a few pointers on making my code more structurally sound.
console.log(wordIsCorrect);
console.log($('.drop-box.spellword').length);
if ($('.drop-box.spellword').length == wordIsCorrect) {
$('.drop-box.spellword').addClass('wordglow2');
$(right).val('Well Done!');
$(right).show();
audioS.play();
$('.counter').html(completeWords + '/6').show();
$(wrong).hide();
$('.minibutton').prop('disabled', false);
var completeLetters = $('.wordglow2').length;
var completeWords = (completeLetters / 3);
$('.counter').html(completeWords + '/6');
if (completeWords == 3) {
$('table').fadeOut(2000);
}
var incompleteWords = $('.spellword').hasClass('.wordglow4').length;
if (incompleteWords == 3) {
$('.minibutton').prop('disabled', false);
}
} else {
$('.drop-box.spellword').addClass("wordglow4").css('color', 'transparent');
$(wrong).val('Try Again');
$('.minibutton').prop('disabled');
$(wrong).show();
audioF.play();
$('.counter').html(completeWords + '/6').show();
$(right).hide();
$('.drop-box.spellword').animate({
'opacity': 1
}, 1000, function() {
$(this).removeClass('wordglow4').removeClass('occupied').html('')
});
}
This one of the if statements in my code. I understand that I should be breaking each task up individually but I don't know where to start.
Can someone point me in the right direction so that I can start tackling the rest of my code. THANKS!