🚀 Day 6/108 – Conditional Statements in JavaScript Continuing my 108-day JavaScript journey — today I learned how to make decisions in code 👇 👉 What are Conditional Statements? They allow us to execute different blocks of code based on conditions. 🧠 Types of Conditional Statements: 🔹 if statement Executes code if a condition is true 🔹 if...else statement Executes one block if true, another if false 🔹 if...else if...else Used to check multiple conditions 🔹 switch statement Used when comparing one value against multiple cases 💻 Example: let age = 18; if (age >= 18) { console.log("You are an adult"); } else { console.log("You are a minor"); } 🧠 Key Insight: Conditions always return either "true" or "false". ⚠️ Quick Note: JavaScript also has truthy and falsy values Falsy values → "false, 0, "", null, undefined, NaN" 🔥 Learning step by step — consistency is everything! How do you usually write conditions — if-else or switch? 👇 #JavaScript #WebDevelopment #CodingJourney #LearningInPublic #100DaysOfCode
JavaScript Conditional Statements Explained
More Relevant Posts
-
🚀 Today I learned one of the most confusing but powerful JavaScript concepts — Prototype. At first, I used methods like .map(), .filter(), and .push() without thinking where they actually come from. Then I understood the role of Prototype 👇 👉 In JavaScript, objects can inherit properties and methods from another object through the prototype chain. Simple Example: function User(name) { this.name = name; } User.prototype.sayHi = function () { console.log("Hi " + this.name); }; const u1 = new User("Sartaj"); u1.sayHi(); 💡 Why use Prototype? ✔️ Shared methods for all instances ✔️ Better memory efficiency ✔️ Faster and cleaner object creation ✔️ Core concept behind JavaScript classes What I understood: prototype → used to store shared methods __proto__ → link to parent object new keyword connects objects to prototype The more I learn JavaScript fundamentals, the more interesting it becomes. 💻 Which JavaScript concept confused you the most at first? 👇 #JavaScript #WebDevelopment #Prototype #Coding #Frontend #MERNStack #Learning #100DaysOfCode
To view or add a comment, sign in
-
-
📚 What I Studied Today – JavaScript Functions & Array Methods Today I strengthened my understanding of some core JavaScript concepts: 🔹 Functions A function is a block of code written once and reused multiple times to perform a specific task. 🔹 Function Definition vs Call - Function Definition: Declares a function with parameters - Function Call: Executes the function using arguments 👉 Parameters = values inside () in definition 👉 Arguments = values inside () in call 🔹 Important Concepts - Parameters act like local variables (accessible only inside the function) - Functions help reduce redundancy (avoid repeating code) - Arrow functions provide a shorter syntax using "=>" 🔹 Callbacks & Higher Order Functions - A callback function is passed as an argument to another function - "forEach()" is a higher order method because it takes a function as input 🔹 Array Methods - "map()" → transforms each element into a new array - "filter()" → selects elements based on a condition - "reduce()" → reduces array to a single value (sum, total, etc.) 🚀 Slowly building a strong foundation in JavaScript! #JavaScript #WebDevelopment #CodingJourney #Learning #MERN
To view or add a comment, sign in
-
-
🚀 Day 4 of Learning JavaScript – Functions Completed! Today I learned one of the most important concepts in JavaScript: **Functions** 💻✨ 🧠 Key concepts I practiced: ✔ What are functions and why we use them ✔ Functions with parameters (inputs) ✔ Return values from functions ✔ Building a mini calculator using functions ✔ Even / Odd number checker logic 💡 What I understood: Functions help us write reusable and clean code. Instead of repeating the same code again and again, we can wrap it inside a function and use it whenever needed. 🔥 Mini Projects I built today: 👉 Calculator function (+, -, *, /) 👉 Even/Odd checker function This step really improved my logical thinking and problem-solving skills in JavaScript. 📌 Next step: DOM (making web pages interactive) #JavaScript #WebDevelopment #CodingJourney #FrontendDevelopment #100DaysOfCode #LearningInPublic
To view or add a comment, sign in
-
-
🔑 Mastering the this keyword in JavaScript! Understanding this can be a game-changer for your JavaScript journey! It can be tricky, but once you get it, your code will be more dynamic and powerful. Here’s a quick breakdown: 🌍 Global Context: In the global scope, this refers to the global object (like window in browsers). 🏠 Object Method: When used inside an object method, this refers to the object itself. 🛠️ Function Context: In regular functions, this defaults to the global object (or undefined in strict mode). 🏃♂️ Arrow Functions: They do not have their own this; they inherit it from the parent scope. 💡 Pro Tip: Use bind(), call(), or apply() to explicitly set the value of this. Follow ABDUL REHMAN ♾️ For More Updates 👍👍 Learn more from w3schools.com , JavaScript Mastery ✨ #JavaScriptTips #WebDevelopment #CodingInsights
To view or add a comment, sign in
-
Day 18 of My JavaScript Journey 🚀 Today, I built my second JavaScript project (A Modal Window.) The project works like this: • Clicking show modal button opens a modal (popup box) • Clicking the close button hides it • Pressing the “Escape” key also closes it In this project, I used: • document.querySelector to select elements • addEventListener to handle user actions • classList to show and hide the modal • keydown event to detect when the ESC key is pressed One thing I found interesting: Handling keyboard events made the project feel more interactive and user-friendly. Key takeaway: JavaScript allows you to control both mouse and keyboard interactions on a webpage. #JavaScript #WebDevelopment #LearningInPublic #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 5/108 – Type Conversion & Type Coercion in JavaScript Continuing my 108-day JavaScript journey — today I learned how JavaScript handles types 👇 👉 Type Conversion (Explicit) Manually converting a value from one type to another. Examples: • "String(123)" → ""123"" • "Number("456")" → "456" • "Boolean(0)" → "false" 👉 Type Coercion (Implicit) JavaScript automatically converts types during operations. Examples: • ""5" + 2" → ""52"" (string) • ""5" - 2" → "3" (number) • "true + 1" → "2" 💻 Example: let str = String(123); // "123" let num = Number("456"); // 456 console.log("5" + 2); // "52" console.log("5" - 2); // 3 🧠 Key Insight: Type coercion can sometimes lead to unexpected results, so it's safer to use explicit conversion when needed. ⚠️ Pro Tip: Always use "===" instead of "==" to avoid unwanted type coercion. 🔥 Learning step by step — consistency is everything! Have you ever faced a bug because of type coercion? 👇 #JavaScript #WebDevelopment #CodingJourney #LearningInPublic #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 2/108 – Variables in JavaScript (var, let, const) Continuing my 108-day JavaScript journey — today I learned about variables 👇 👉 What are Variables? Variables are containers used to store data values in a program. In JavaScript, we mainly use 3 types: var, let, and const 🔹 var • Old way of declaring variables • Function scoped • Can be re-declared and updated 🔹 let • Block scoped • Can be updated but not re-declared in the same scope 🔹 const • Block scoped • Cannot be updated or re-declared • Must be initialized when declared 💻 Example: var name = "John"; let age = 22; const country = "India"; age = 23; // allowed // country = "USA"; ❌ not allowed 🧠 Key Insight: Always prefer let and const over var in modern JavaScript. 🔥 Learning step by step — consistency is the key! Are you using var, let, or const in your projects? 👇 #JavaScript #WebDevelopment #CodingJourney #LearningInPublic #108DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 979 of #1000DaysOfCode ✨ 4 Useful Number Functions in JavaScript (With Cool Examples) JavaScript provides many built-in number utilities — but most developers only use a few of them. In today’s post, I’ve shared 4 super useful number functions in JavaScript along with some cool and practical examples for each. These functions can help you handle number validation, formatting, and edge cases more effectively in real-world applications. Small utilities like these might look simple, but they can save you time and help you write cleaner and more reliable logic. Once you start using them properly, you’ll notice how often they come in handy while working with data. If you work with numbers, calculations, or user inputs in JavaScript, these functions are definitely worth knowing. 👇 Which JavaScript number function do you use the most in your projects? #Day979 #learningoftheday #1000daysofcodingchallenge #FrontendDevelopment #WebDevelopment #JavaScript #React #CodingCommunity #JSDevelopers
To view or add a comment, sign in
-
Useful JavaScript Tricks Developers Should Know 🚀 JavaScript has some powerful features that can make your code cleaner and more efficient. Here are a few JavaScript tricks I use regularly: 🔹 Destructuring Extract values from objects easily const { name, age } = user; 🔹 Optional Chaining Avoid undefined errors user?.profile?.name 🔹 Default Parameters Set default values function greet(name = "Developer") { return `Hello ${name}`; } 🔹 Spread Operator Copy arrays or objects const newArray = [...oldArray]; 🔹 Short Circuit Evaluation Cleaner conditional logic isLoggedIn && showDashboard() These small tricks can make your code more readable and efficient. Still learning JavaScript every day 🚀 What’s your favorite JavaScript trick? #JavaScript #FrontendDeveloper #ReactNative #SoftwareEngineer #CodingTips #WebDevelopment
To view or add a comment, sign in
-
-
Day 5 of My JavaScript Journey 🚀 Today, I learned about if/else statements and type conversion in JavaScript. The if/else statement is used to control the flow of a program based on conditions. Example: if (age > 18) { console.log("Adult"); } else { console.log("Not an adult"); } I also learned about type conversion and coercion. • Type conversion is when we manually change a value from one type to another. • Type coercion is when JavaScript automatically converts types behind the scenes. For example: "5" + 2 = "52" (coercion happens) One thing that stood out to me: JavaScript can behave unexpectedly if you don’t understand type coercion. Key takeaway: Always be mindful of data types when writing conditions and operations. #JavaScript #WebDevelopment #LearningInPublic #100DaysOfCode
To view or add a comment, sign in
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development