Untitled

 avatar
user_7147158
plain_text
17 days ago
1.6 kB
4
Indexable
Never
// Write an if-else condition to check if a person is eligible to vote based on their age (must be 18 or older).

// let age = 18;
// if(age >= 18){
//     console.log("elgible for vote");
// }
// else{
//     console.log("not eligible")
// }

// Write an if-else statement that assigns a grade based on the following conditions:
// If marks are 90 or above: Grade A
// If marks are 80 or above but less than 90: Grade B
// If marks are 70 or above but less than 80: Grade C
// If marks are below 70: Grade D

// let marks = 40;
// if(marks >= 90){
//     console.log("Grade A");
// }
// else if(marks >= 80 && marks < 90){
//     console.log("grade b")
// }
// else if(marks >= 70 && marks < 80){
//     console.log("grade c")
// }
// else {
//     console.log("grade d")
// }


// agar koi year 4 se divide ho and 100 se divide nhi ho yaa 400 se divide ho

// let year = 1900;
// if((year % 4 == 0 && year % 100 != 0) || year % 400 == 0){
//     console.log("leap year")
// }
// else {
//     console.log("not leap year")
// }

// Given a variable grade (a string of "A", "B", "C", "D", "F"), use a switch statement to log a message indicating whether the grade is passing or failing.

let temp = "D";
switch (temp) {
    case "A":
        console.log("paas")
        break;
    case "B":
        console.log("paas")
        break;
    case "C":
        console.log("paas")
        break;
    case "D":
        console.log("fail")
        break;
    case "F":
        console.log("paas")
        break;
    default:
        console.log("paas")
        break;
}
Leave a Comment