samedi 3 avril 2021

How to set output in a variable from conditional statement in javascript

I make a condition with Else-If to print a line like [You got A+, You got D]. Now I want to store one valid output line in a variable outside the condition.

var gradeMark = Math.round(totalNumber / 6);

//Generate grade mark
if (gradeMark >= 80) {
    console.log("You got A+");
} else if (gradeMark >= 70) {
    console.log("You got A");
}....
.....
else if (gradeMark >= 0) {
    console.log("You got F");
} else {
    console.log("It's not valid mark");
}

//Getting grading mark
var validGradeMark = 

Aucun commentaire:

Enregistrer un commentaire