Let’s dive deeper into JavaScript today! We’ve learned about variables, now let's explore data types and how to declare variables with let and const. Here’s the breakdown:
1. Data Types: Variables store different types of data:
- String: Text like
'Hello'- Number: Numbers like
25- Boolean: True/false values like
truelet myName = 'Sifen'; // String
let age = 20; // Number
let isLearningJS = true; // Boolean
console.log(myName, age, isLearningJS);
2. let vs const:
- let allows you to change the value later.
- const is for values that never change.
let score = 10;
score = 15; // This works!
const birthYear = 2004;
birthYear = 2005; // This gives an error!
Use let when the value might change, and const for constants. Understanding how to handle data types and declarations will make coding a lot easier!
#JavaScriptBasics #LearningJourney #WebDevelopment
Please open Telegram to view this post
VIEW IN TELEGRAM
👏8👍2🔥1
Today’s all about conditional statements! These allow our code to make decisions based on conditions, making it interactive and dynamic. Let’s break down the basics:
1. if Statements: Run code only if a condition is true.
2. else if and else: Add more conditions and a fallback if none match.
let age = 18;
if (age >= 18) {
console.log("You're an adult! 🎉");
} else {
console.log("You're still a minor! 🧒");
}
3. Switch Statements: Useful when checking multiple conditions for one variable.
let day = "Monday";
switch(day) {
case "Monday":
console.log("Start of the week grind! 💪");
break;
case "Friday":
console.log("Weekend’s almost here! 🎉");
break;
default:
console.log("Another day, another code! 🤓");
}
These statements are key to adding decision-making power to your code! 💥 Keep Pushing!
#JavaScriptBasics #Day4 #ConditionalStatements #WebDevelopment
Please open Telegram to view this post
VIEW IN TELEGRAM
⚡2👍2