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 it on 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 both the conditions must be true and if one is 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 have any doubts any queries please mention them in the comments below.
Motivation for Today: "Always believe that something wonderful is about to happen...โฅ"
ย