Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

basics of switch case and if else

//switch case
let marks=91;

switch(true){
    case (marks>90):
        console.log("Super Grade");
        break;
    case (marks > 50):
        console.log("Pass");
        break;
    case (marks < 50):
        console.log("Fail");
        break;
    default:
        console.log("Unknown Grade")
}


//If Else

let mark=91;

if (mark > 90) {
       console.log("Super Grade");
} else if (marks > 50){
     console.log("Pass");
}else if(marks < 50 ){
    console.log("Fail");
}else{
    console.log("Unknown Grade")
}
 
PREVIOUS NEXT
Tagged: #basics #switch #case
ADD COMMENT
Topic
Name
2+2 =