HEADER ADS 728X90

How to use If, Else, and Else-if conditional statement in javascript | Javascript Tutorial | By Codeprime

javascript,tutorial,code prime,if else if statement,javascript if statement multiple conditions,if statement syntax,if else statement syntax,how to write an if statement in javascript if i=5,javascript conditionals,if else condition in html code,if else statement in java,javascript tutorial for beginners,javascript tutorial,types of conditional statements in javascript,How many conditional statements,if,else,else-if,if statement in java, codeprime, coding tutorial, how to learn coding easy way to learn coding

Hi dear welcome to "CodePrime" Blog . In this post you are going to learn How to use If, Else, and Else-if conditional statement in javascript. First Creat A index.html file Copy This HTML CODE and pest it one your code editor. 2ndly creat if-else-if.js file Then Copy The JS CODE and pest it. Next connect if-else-if.js file with your index.html then open the index.html file with your browser.

HTML CODE

<!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">
    <script src="/js/if-else-if.js"></script>
    <title>javascript</title>
</head>
<body>
    <h2>Javascript Tutorial</h2>
    <h3>By Codeprime</h3>
   
</body>
</html>

JAVASCRIPT CODE

let numbers=[];
numbers=[1,2,1,2,3,1,2];

if(numbers[0]==numbers[2]) {
    console.log('its correct');
};

// if else example

if(numbers[0]==numbers[3]) {
    console.log('its correct');
} else{
    console.log(' its wrong');
}

//else-if example

if(numbers[0]==numbers[3]) {
    console.log('1st block');
} else if (numbers[1]==numbers[3]) {
    console.log(' 2nd block');
} else {
    console.log(' 3rd block');

}

Youtube Tutorial

FLOW US ON SOCIAL MEDIA

Post a Comment

0 Comments

Join Telegram