Today’s focus is on comparison and logical operators. These are essential for making decisions in your code. Let’s dive in!
1. Comparison Operators:
-
== checks if values are equal -
=== checks if values and types are equal -
> greater than, < less than -
!= checks if values are not equal let age = 18;
console.log(age == '18'); // true (only checks value)
console.log(age === '18'); // false (checks both value and type)
2. Logical Operators:
-
&& (AND) checks if both conditions are true -
|| (OR) checks if one of the conditions is true -
! (NOT) negates a condition let isAdult = true;
let hasID = false;
console.log(isAdult && hasID); // false (because one is false)
console.log(isAdult || hasID); // true (because one is true)
These operators will help you build logic and control the flow of your apps! 🔥 Keep pushing!
#JavaScriptLearning #Day3 #WebDevJourney #CodingLife #LogicalThinking
Please open Telegram to view this post
VIEW IN TELEGRAM
👍4🔥1