mercredi 31 mars 2021

Trying to make for loop that updates grade as age raises

I am currently developing a website for some tutoring services I host. I am making a for loop that automatically updates my grade as my age increases. I have the loop written out, but for some reason it is not working as intended. I am usually good with JS, but it is always the loops (for) that get me! Any help would be appreciated! Thanks!

var finalGrade;
function grade() {
    for (i = 10; i <= 12; i++) {
        if (i === 10) {
            finalGrade = 10;
            return grade;
        } else {
            finalGrade = finalGrade++;
            return grade;
        }

    }
};
console.log(grade(finalGrade));

Thank you for spending your time helping me fix my bugs! Feel free to comment easier ways to do what I am trying to do!




Aucun commentaire:

Enregistrer un commentaire