JS Tutorial #4: Conditional Statements Title: JS Tutorial #4: If-Else Statements Content: Conditional statements let your program make decisions. Code snippet: let score = 75; if(score >= 50) { console.log("Pass"); } else { console.log("Fail"); } Engagement: Change the score variable and see what happens. Can you add else if for a grade system? #JavaScript #WebDevelopment #Coding #LearnJS #Cognothink
JS Tutorial: Conditional Statements with If-Else
More Relevant Posts
-
JS Tutorial #3: Functions Title: JS Tutorial #3: Functions in JavaScript Content: Functions are reusable blocks of code. They help organize your program. Code snippet: function greet(name) { return `Hello, ${name}!`; } console.log(greet("Cognothink")); Engagement: Write a function that takes two numbers and returns their sum. Try it out! #JavaScript #WebDevelopment #Coding #LearnJS #Cognothink
To view or add a comment, sign in
-
Learning by building: wrote a simple JS program that takes a number and prints its multiplication table with clean loops, input validation, and readable template strings. Small steps, consistent commits, better logic every day. 🚀 #JavaScript #VSCode #100DaysOfCode #BuildInPublic”
To view or add a comment, sign in
-
-
⚙️ JavaScript Tip That Saves You Debugging Time ⏱️ Ever log multiple values in JS and get confused which is which? Try this simple trick 👇 console.log({ user, score, status }); ✅ Instead of random logs — you get clear labeled output: { user: "Vinod", score: 98, status: "active" } No more guessing what’s what. Small habit → cleaner debugging, faster fixes. 💡 #JavaScript #WebDevelopment #FullStackDeveloper #CodingTips #DeveloperVinod #Debugging
To view or add a comment, sign in
-
-
Day 4 of #30DaysOfJavaScript on LeetCode Today's challenge: 2665 — Counter II 🔁 The task was to create a createCounter function that accepts an initial integer init and returns an object with three functions: increment() → increases the value by 1 decrement() → decreases the value by 1 reset() → resets the value back to init Here’s my solution 👇 var createCounter = function(init) { let cache = init; return { increment: function() { return ++init; }, reset: function() { init = cache; return cache; }, decrement: function() { return --init; } }; }; This challenge was a good exercise in understanding closures and object methods — it’s cool how functions can maintain state in JavaScript! 💡 If you’d like to try it out, check it here: https://lnkd.in/g6WC5mu7 #JavaScript #LeetCode #CodingChallenge #LearningJourney #Closures #30DaysOfCode #Functions #Objects #Programming
To view or add a comment, sign in
-
-
Day 6 of #30DaysOfJavaScript on LeetCode Today's challenge: 2634 — Filter Elements from Array The task was to implement a custom filter function that returns a new array containing only the elements that satisfy a given condition — similar to the built-in Array.filter() method, but without using it. Here’s my solution 👇 var filter = function(arr, fn) { let ans = []; for (let i = 0; i < arr.length; i++) { if (fn(arr[i], i)) ans.push(arr[i]); } return ans; }; This challenge was a great way to understand how callback functions and conditional logic work together in JavaScript — it really helps appreciate how built-in methods like filter() operate under the hood! If you’d like to try it out, check it here: https://lnkd.in/g6WC5mu7 #JavaScript #LeetCode #CodingChallenge #LearningJourney #30DaysOfCode #Functions #Callbacks #Arrays #Programming #Filter
To view or add a comment, sign in
-
-
Recently I was preparing for JavaScript and I stumbled upon a simple concept — but most people don’t know the key differences between var and let. Here’s a quick example: ` for (var i = 0; i < 3; i++) { setTimeout(() => console.log(i), 1000); } // Output: 3 3 3 ` ` for (let i = 0; i < 3; i++) { setTimeout(() => console.log(i), 1000); } // Output: 0 1 2 ` Key differences: Scope: var is function-scoped, let is block-scoped. Hoisting & Temporal Dead Zone: var is hoisted and initialized with undefined, let is hoisted but not initialized — accessing it before declaration throws a ReferenceError. Understanding these small details can save you from tricky bugs, especially in loops and async code! #JavaScript #JS #WebDevelopment #FrontendDevelopment #Coding #LearnToCode #DeveloperTips #TechCommunity #CodeSnippet #Programming ## I’d appreciate it if you could share a few more examples to help me understand.
To view or add a comment, sign in
-
React Hooks Deep Dive: The Complete Guide (PDF Attached) Following up on my previous post about useMemo and useCallback, I've expanded it into a comprehensive guide covering all 11 essential React Hooks. What's Inside: - useState & useEffect fundamentals - useContext for cleaner state access - useRef for DOM manipulation & persistence - useMemo & useCallback (expanded from last post) - useReducer for complex state logic - useLayoutEffect for synchronous updates - Modern hooks: useId, useDeferredValue, useTransition #React #WebDevelopment #JavaScript #Frontend #ReactHooks #Programming #SoftwareEngineering #WebDev #TypeScript #Development
To view or add a comment, sign in
-
javascript Logic Challenge #3 how to count the digits of a number in JS Simple Explanation : Imagine a number like 567. We want to know how many numbers are inside it. So we do this: 1. Take the number 2. Remove the last digit 3. Each time you remove a digit - count +1 4. Stop when the number becomes 0 That’s it! Example: 567 - 3 digits I used a simple loop that removes one digit at a time and counts it. #JavaScript #Learning #LogicBuilding
To view or add a comment, sign in
-
-
Keyboard Events in JavaScript Keyboard events make web pages more interactive by detecting when users press or release keys. These events help in creating shortcuts, form controls, and smooth navigation experiences. ✨The three main keyboard events are: 🔹keydown – triggered when a key is pressed. 🔹keypress – triggered while the key is held down (mostly for character keys). 🔹keyup – triggered when the key is released. #JavaScript #WebDevelopment #Coding #WebDesign #FrontendDevelopment #Stemup
To view or add a comment, sign in
-
Ever felt lost in the complexities of the Node.js EVENT LOOP? 🤔 Let's demystify this core concept for better JavaScript performance! The Node.js Event Loop (powered by V8 and libUV) is the HEARTBEAT ❤️ of asynchronous JavaScript. Understanding it is CRUCIAL for writing efficient Node.js applications. Here are three key takeaways: 💡 Grasp the difference between BLOCKING and NON-BLOCKING I/O. Blocking I/O halts the entire process, non-blocking doesn't. ⏱️ Understand the nuances of `setImmediate` vs. `setTimeout(0)`. While seemingly similar, they behave differently in the event loop's execution order. `setImmediate` prioritizes I/O cycle, while `setTimeout(0)` goes to the timer queue. 🧵 Optimize your UV_THREADPOOL_SIZE. This determines the number of threads available for asynchronous operations. Increasing it can boost performance for CPU-intensive tasks. What's YOUR favorite Node.js performance tip? Share in the comments! 👇 #Nodejs #JavaScript #EventLoop #Asynchronous #Programming #Backend #Performance
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