Hello Legends!! π
So, this is my Part-9 for JavaScript for Beginners!!β
Let's get started!!β‘
1.Greater than sign in JSπ₯
// Comparision with the greater than sign!!
function letsCheck(isItGreater) {
// Created a function
if (isItGreater > 100) {
// Checking
return "It is greater than 100!"; // returning
}
return "It is 100 or less!"; // returning
}
console.log(letsCheck(200)); // Output: It is greater than 100!
Output:
It is greater than 100!
Run this code and understand by your own.
2. Greater than equals sign πͺ
// Comparision with Greater than equals operators!
function letMeCheck(isItGreaterEquals) {
//Created a function
if (isItGreaterEquals >= 100) {
//check if it is greater or equal to 100
return "100 or Over"; //returning
}
return "Less than 100"; //returning
}
console.log(letMeCheck(100)); // Output: 100 or Over
Output:
100 or Over
I want you to write it, run it, understand it! π
3. Less than sign in JS π©
// Comparision with the less than sign!!
function lessThan(isItLess) {
// Created a function
if (isItLess < 50) {
// Checking if it is less than
return "It is less than 50"; // returning
}
return "It is 50 Or Greater"; // returning
}
console.log(lessThan(40)); // Output: It is less than 50
Output:
It is less than 50
Hopefully that went well π
4. Less than equals sign πͺ
// Comparision with Less than equals operators!
function lessThanEquals(isItLessEquals) {
// Created a function
if (isItLessEquals <= 100) {
// checking if it is less than or equals to 100
return "100 or Less"; // returning
}
return "Greater than 100"; // returning
}
console.log(lessThanEquals(40)); // Output: 100 or Less
Output:
100 or Less
5. Understand And(&&)
Operator π
Basically &&
Operator means we will check that if both the conditions are true also it's compulsory that both the conditions must be true and if one will be wrong then it will not work!! π
// Understand And(&&) Operator
function letsCheckAnd(num) {
// created a function
if (num <= 20 && num >= 10) {
// Check it
}
return "Yes"; // returning
return "No"; // returning
}
console.log(letsCheckAnd(14)); // Output: Yes, because both the conditions are true!
// And if we put a number like 140 so it will be no
// because there will be only the second condition true!π
Output:
Yes
6. Understand Or( || )
OperatorπΉ
Basically Or ( || ) operator means that if one statement is true then also it will work!! π
// Understand Or ( || ) Operator
function testOr(val) {
// Created function
if (val < 10 || val > 20) {
// checking
return "Outside"; // returning
}
return "Inside"; // returning
}
console.log(testOr(21)); //Output: Outside, because the second statement is true!
Output:
Outside
So that is it for today guys, if you are having any doubt any query please mention it in the comments below.
Motivation for Today: "Always believe that something wonderful is about to happen...β₯"
I will see you all again in the next article which will be Part-10 till then take care and Goodbyeee!! π