DAY -5
SWITCH CASE
in javascript switch case is used to already stored data will getting the particular value or case number
syntax for switch case:
switch (user given value ){
    case 1:
        console.log("stored data");
        break;
    case 2:
        consloe.log ("another store data");
        break;
    default:
            console.log("user will given the invaild data");
}
sample code:
find the day of the week useing switch case
 <script>
        let day =4;//user give data
        switch(day){
            case 1 :
                console.log("monday");
                break;
            case 2 :
             console.log("tuesday");
             break;
            case 3:
                console.log("wesday");
               break;
            case 4:
                console.log("thrusday");
                break;
             case 5:
                console.log("friday")
              break;
        default:
            console.log("Enter Valued Input");
        }  //output : thrusday
MINI PROJECT : 1
COLLECT THE DATA FROM THE USER AND CREATE THE LOGIN AND PASSWORD ,USING PROMPT
<script>
const userName = "vicky"; // ALREADY STORE DATA 
        const Password = "1324"; 
    const userinputName = prompt("ENTER THE MAIL-ID"); //
    const inputPassword = prompt("ENTER THE PASSWORD")
    console.log(userinputName);
    console.log(inputPassword);
    if (userName === userinputName && Password === inputPassword) {
        alert("login successfully")
        const options = prompt("WELCOM TO HOME-PAGE!\n1.view profile \n 2 setting page \n 3.adimin page");
        switch (options) {
            case "1":
                alert(`username : ${userName}\n password : ${Password}`);
                break;
            case "2":
                alert(`menu \n privacy \n logout`);
                break;
            case "3":
                alert(`EDITED all code and setting with admin login`);
                break;
            default:
                alert("invaild data");
                break;
        }
    }
    else {
        alert("INVALID USERNAME AND PASSWORD")
    }
PROJECT OUTPUT LINK :
    https://front-end-project692430.gitlab.io/-/front-end/-/jobs/11240913023/artifacts/public/miniproject1.html
 

 
    
Top comments (0)