Index.html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <center>
        <button onclick="sum()">
            Shown result
        </button>
    </center>
    <script src="js/script.js"></script>
</body>
</html>
Script.js
const sum = () => {
    let a = prompt("enter value for a")
    let b = prompt("enter value for b")
    let op = prompt("Enter the value for Operation (+ , -, /, *)")
    // if (op == "+") {
    //     let result = parseInt(a) + parseInt(b)
    //     alert(result)
    // }
    // else if (op == "-") {
    //     let result = parseInt(a) - parseInt(b)
    //     alert(result)
    // }
    // else if (op == "*") {
    //     let result = parseInt(a) * parseInt(b)
    //     alert(result)
    // }
    // else if (op == "/") {
    //     let result = parseInt(a) / parseInt(b)
    //     alert(result)
    // }
    // else {
    //     alert("You Entered Wrong Oprator!")
    // }
    let result
    switch (op) {
        case "+":
            result = parseInt(a) + parseInt(b)
            alert(result)
            break;
        case "-":
            result = parseInt(a) - parseInt(b)
            alert(result)
            break;
        case "*":
            result = parseInt(a) * parseInt(b)
            alert(result)
            break;
        case "/":
            result = parseInt(a) / parseInt(b)
            alert(result)
            break;
        default:
            alert("You Entered Wrong Oprator!")
            break;
    }
 //OR
    if (result >= 10 || result <= 20) {
        console.log("vlaue is greater then 10")
    }
    // AND
     else if (result >= 10 && result <= 20) {
        console.log("vlaue is greater then 10")
    }
    else if(result != 21) { 
    }
//Not
    let val = true
    if (!val) { }
    if (val != true) { }
}
Comments
Post a Comment