🚀 30 Days of JavaScript – Day 13 Today I built a Tip Calculator with Bill Split Feature. This tool calculates: • Tip amount • Total bill • Amount each person should pay when splitting the bill. 🧠 Concepts Used: user input handling arithmetic calculations variables and type conversion 🎥 Demo below 👇 Full source code in the First comment. #JavaScript #WebDevelopment #CodingJourney #LearningJavaScript #ProblemSolving
More Relevant Posts
-
𝗟𝗼𝗼𝗽𝗶𝗻𝗴 𝗦𝘁𝗮𝘁𝗲𝗺𝗲𝗻𝘁𝘀 𝗜𝗻 𝗝𝗦 Looping statements in JavaScript repeat a block of code until a condition becomes false. You use loops to make your code shorter and easier to manage. JavaScript provides the following loops: - for Loop: used when you know how many times the loop should run - while Loop: runs as long as the given condition is true You can use loops to print numbers, find multiples, or count divisors. For example, you can print numbers from 1 to 5 using a for loop: for (let i = 1; i <= 5; i++) { console.log(i); } This prints: 1 2
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
-
𝗛𝗼𝘄 𝗜 𝗕𝘂𝗶𝗹𝘁 𝗮 𝗛𝗲𝗶𝗴𝗵𝘁 𝗣𝗿𝗲𝗱𝗶𝗰𝘁𝗼𝗿 𝗖𝗮𝗹𝗰𝘂𝗹𝗮𝘁𝗼𝗿 𝗨𝘀𝗶𝗻𝗴 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 You want to build a height predictor calculator. I did it using JavaScript. Here's how: - I used JavaScript to create the calculator - I added a simple user interface - I made it easy to use You can build one too. Start with basic JavaScript concepts. Then add your own features. Source: https://lnkd.in/gMB8Fch8
To view or add a comment, sign in
-
Most developers get confused by the JavaScript Event Loop 🤯 Here’s the simplest way to understand it: JavaScript is single-threaded — it runs one task at a time. But async tasks (setTimeout, API calls, promises) don’t block the code. 👉 They go to Web APIs (handled by browser) 👉 Then move to a Queue 👉 Event Loop pushes them back when the stack is empty Example: console.log("Start") setTimeout(() => console.log("Timeout"), 0) console.log("End") Output: Start End Timeout Even 0ms delay runs last 😲 Bonus: Promises run before setTimeout because they use Microtask Queue ⚡ Have you struggled with Event Loop before?
To view or add a comment, sign in
-
-
🧠 Day 4 of 21 days challenge JavaScript Hoisting 🤯 // var → undefined // let/const → error Why different behavior? Hoisting is a JavaScript behavior where variable and function declarations are moved to the top of their scope before execution. Only declarations are hoisted, not initializations. For easy understanding :- Hoisting = moving declarations to top var is hoisted with undefined let & const are hoisted but not initialized 👉 That’s why var gives undefined but let/const give error For example :- Normal code : console.log(score); // undefined var score = 90; JS will do this internally: var score; // first reserve console.log(score); // undefined score = 90; // then assign value This changed how I understand variable behavior 🚀 #JavaScript #Hoisting #Frontend
To view or add a comment, sign in
-
-
🚀 30 Days of JavaScript – Day 16 Starting to build more structured programs using JavaScript. 💡 Today’s Project: Contact Manager This program allows users to: • Add contacts (name & phone) • View stored contacts 🧠 Concepts Used: • functions • arrays of objects • oops • menu-driven logic This helped me understand how to organize code into reusable functions. 🎥 Demo below 👇 Full source code in the First comment. #JavaScript #WebDevelopment #CodingJourney #LearningJavaScript #ProblemSolving
To view or add a comment, sign in
-
🧠 Day 3 of 21 days challenge JavaScript Event Loop 🤯 Event Loop is a mechanism in JavaScript that handles execution of asynchronous code. It continuously checks the call stack and callback queue. If the stack is empty, it moves tasks from the queue to the stack for execution. For example :- console.log("Start"); console.log("End"); console.log("Timeout"); Wait… why this order? Because JavaScript doesn’t run everything instantly. It uses: • Call Stack • Web APIs • Callback Queue Event Loop decides what runs next. 💤For easy understanding :- Event Loop = decides execution order Sync code runs first Async code waits in queue Then runs after the stack is empty 👉 That’s why “Timeout” runs last This changed how I understand async code 🚀 #JavaScript #EventLoop #Async
To view or add a comment, sign in
-
-
𝗦𝗮𝗺𝗽𝗹𝗲 𝗼𝗳 𝗙𝘂𝗻𝗰𝗍𝗶𝗼𝗻 You write a function once, you use it many times. In JavaScript, a function is a block of code that performs a specific task. You have several types of functions, including: - Function Declaration - Function Expression - Arrow Function - Anonymous Function - Named Function - Callback Function - IIFE - Recursive Function - Higher-Order Function - Constructor Function - Generator Function - Async Function - Method Source: https://lnkd.in/gRkjbBt8
To view or add a comment, sign in
-
𝗖𝗿𝗮𝗰𝗸 𝘁𝗵𝗲 𝗖𝗼𝗱𝗲: 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗛𝗼𝗶𝘀𝘁𝗶𝗻𝗴 𝗘𝘅𝗽𝗹𝗮𝗶𝗻𝗲𝗱! 🤔 Ever seen code that works even though you call a function before defining it? That's the magic (and potential trap) of Hoisting! 🪄 Here is a simple breakdown of this essential JS concept: What is it? Think of it as the JavaScript engine giving your declarations a "lift." Before running your code, it moves function and variable declarations (not their values!) to the top of their scope. ⬆️ 𝗩𝗮𝗿𝗶𝗮𝗯𝗹𝗲𝘀 𝘄𝗶𝘁𝗵 𝘃𝗮𝗿: These are hoisted and initialized to undefined. You can access them, but they won't have their values yet. 🤷♂️ 𝗩𝗮𝗿𝗶𝗮𝗯𝗹𝗲𝘀 𝘄𝗶𝘁𝗵 𝗹𝗲𝘁 & 𝗰𝗼𝗻𝘀𝘁: These are hoisted but not initialized. Accessing them before they're defined throws an error—a safe space known as the Temporal Dead Zone (TDZ)! 🛑🚫 𝗙𝘂𝗻𝗰𝘁𝗶𝗼𝗻𝘀: Full function declarations are hoisted, allowing you to call them anywhere in their scope. (This is super convenient!) 🤩 Understanding hoisting is crucial for avoiding confusing bugs and writing cleaner, more predictable code. 🧱💻 Check out this diagram for a visual guide! #JavaScript #WebDevelopment #CodingTips #SoftwareEngineering #Hoisting #TemporalDeadZone #LearningToCode #WebDev
To view or add a comment, sign in
-
-
JavaScript Concept: What is Tree Shaking? Answer: Tree Shaking removes unused code from your bundle. Example: import { add } from "./utils" If other functions are unused, they won’t be included. Explanation: Bundlers like: • Webpack • Vite • Rollup analyze imports and remove dead code. Benefits: 1. smaller bundle size 2. faster load time 3. better performance Important: Tree shaking works best with ES modules (import/export). Follow-up: Have you checked your bundle size recently? #javascript #WebPerformance #FrontendOptimization
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
let bill = prompt("Enter the bill amount:"); let tipPercent = prompt("Enter tip percentage:"); let people = prompt("How many people are sharing the bill?"); bill = Number(bill); tipPercent = Number(tipPercent); people = Number(people); let tipAmount = (bill * tipPercent) / 100; let totalBill = bill + tipAmount; let perPerson = totalBill / people; alert("Tip Amount: " + tipAmount); alert("Total Bill: " + totalBill); alert("Each Person Pays: " + perPerson);