What is String Concatenation in JavaScript? String concatenation means joining two or more strings (text values) together into one string. Why it’s used We use string concatenation when we want to: Combine multiple pieces of text together Insert variable values inside text Example 1: let firstName = "Maruf"; let lastName = "Hossen"; let fullName = firstName + " " + lastName; console.log(fullName); Output: Maruf Hossen Example 2: let name = "Maruf"; let age = 25; let info = `My name is ${name} and I am ${age} years old.`; console.log(info); Output: My name is Maruf and I am 25 years old. #html #css #javascript #react #webdesign #webdeveloping
How to concatenate strings in JavaScript
More Relevant Posts
-
Built a Random Quote Generator using JavaScript 🧠✨ Every click gives a new motivational quote! It helped me understand arrays, random numbers, and DOM updates — plus for me, it’s fun to use 😄. full code:https://lnkd.in/gRQ_YrJU #javascript #webdevelopment #learningjourney #html #css
To view or add a comment, sign in
-
🚀 JavaScript Trick You Should Know! What do you think the result will be? 👇 "5" + 2 // ? "5" - 2 // ? ✅ "5" + 2 → "52" ✅ "5" - 2 → 3 Why? Because (+) combines strings, while (-) forces JavaScript to convert "5" into a number. A small example — but it shows how type coercion can completely change your output. ⚡ #JavaScript #FrontendDevelopment #CodingTips
To view or add a comment, sign in
-
What is if else in JavaScript? In JavaScript, the if else statement is used to make decisions in your code. It allows your program to run different blocks of code depending on whether a condition is true or false. Syntax: if (condition) { // code to run if condition is true } else { // code to run if condition is false } Example 1: let age = 18; if (age >= 18) { console.log("You are an adult!"); } else { console.log("You are a minor!"); } Output: You are an adult! Example 2: Checking even or odd number let number = 7; if (number % 2 === 0) { console.log("Even number"); } else { console.log("Odd number"); } Output: Odd number #html #css #javascript #react #webDesign #wevdeveloping
To view or add a comment, sign in
-
-
Exploring Different Methods to Calculate the Sum of Two Numbers in JavaScript When it comes to adding two numbers in JavaScript, there are various approaches to achieve the result. One common method involves defining variables for the numbers, such as: var a = 2; var b = 3; function sum(){ return a + b; } sum(); Alternatively, you can directly pass the numbers into a function for instant calculation: function sum(a, b){ return a + b; } sum(2, 3); For real-time feedback while coding, utilizing "console.log" can display the result promptly: function sum(a, b){ console.log(a + b); } sum(2, 3); Remember, JavaScript's case sensitivity emphasizes the importance of accurately typing uppercase and lowercase letters in your code. Stay precise for seamless execution! #JavaScriptTips #CodingMethods #JavaScript
To view or add a comment, sign in
-
#Javascript #Linkedin #interviewpractices #simpleanswer What is for...in and for...of in javascript? Ans: for...in: Used to loop over the keys(property names) of an object. It gives you indexes when used with arrays. for...of: Used to loop over the values of an iterable(like arrays, strings, etc). It gives you values, not key. In short: for...in → loops through keys/indexes. for...of → loops through values
To view or add a comment, sign in
-
-
Variable Declarations @ JavaScript Simplified👨💻 In JavaScript, we have three keywords to declare variables: var, let, and const. 💢Each behaves differently when it comes to redeclaration and reassignment 👇 🔸 var ✅ Redeclaration: Allowed ✅ Reassignment: Allowed 🧩 Example: var x = 10; var x = 20; // works fine ⚠️ Best avoided — can cause accidental overwriting of variables. 🔸 let ❌ Redeclaration: Not allowed ✅ Reassignment: Allowed 🧩 Example: let y = 30; y = 40; // valid let y = 50; // ❌ SyntaxError 👍 Use let when the value of a variable might change later. 🔸 const ❌ Redeclaration: Not allowed ❌ Reassignment: Not allowed 🧩 Example: const z = 50; z = 60; // ❌ TypeError 🔒 Use const for values that should never change. 👉 Quick recap: 🔹Use let when updates are needed. 🔹Use const when the value stays fixed. 🔹Avoid var to keep your code predictable and clean. #JavaScript #WebDevelopment #CodingTips #LearningJS #FrontendDevelopment
To view or add a comment, sign in
-
Tell me about JavaScript 𝗽𝗿𝗶𝗺𝗶𝘁𝗶𝘃𝗲 𝘁𝘆𝗽𝗲𝘀: In JavaScript there are 7 primitive types: 𝗻𝘂𝗹𝗹, 𝘂𝗻𝗱𝗲𝗳𝗶𝗻𝗲𝗱, 𝘀𝘁𝗿𝗶𝗻𝗴, 𝗻𝘂𝗺𝗯𝗲𝗿, 𝗯𝗼𝗼𝗹𝗲𝗮𝗻, 𝘀𝘆𝗺𝗯𝗼𝗹, 𝗯𝗶𝗴𝗶𝗻𝘁. All primitive types are 𝗶𝗺𝗺𝘂𝘁𝗮𝗯𝗹𝗲, that is, they cannot be altered. They don't have methods, but they behave like they do. When properties are accessed on primitives, JavaScript 𝗮𝘂𝘁𝗼-𝗯𝗼𝘅𝗲𝘀 the value into a wrapper object. It makes possible to run some operations over the value, like 𝘁𝗼𝗙𝗶𝘅𝗲𝗱 in Number or 𝗰𝗵𝗮𝗿𝘁𝗔𝘁 in String. The object is discarded right after the operation completes. When passing a primitive value to a 𝗳𝘂𝗻𝗰𝘁𝗶𝗼𝗻, a copy of the value will be passed. This means that the original value and the value passed through the function have different space in memory. Use the comments if you have some addition or a simpler way to explain this. #javascript #techinterview #jobinterview #question #interviewquestion
To view or add a comment, sign in
-
-
a stopwatch built with HTML, CSS, and JavaScript! ⏱️ This was a fantastic exercise in handling DOM manipulation, managing state, and working with timing events (setInterval/clearInterval). Always learning, always building! #WebDevelopment #JavaScript #HTML #CSS #Projects #LearningToCode #FrontEndDevelopment
To view or add a comment, sign in
-
🚀 Dynamic DOM Manipulation with JavaScript 💻 Just explored how to create an unordered list dynamically using JavaScript DOM methods like createElement(), appendChild(), and textContent. No hardcoding — everything gets generated through JS! 🔥 This small step helped me understand how JavaScript interacts with the DOM and how elements can be created, modified, and added dynamically. 🌿 💡 Tech used: HTML, JavaScript (DOM) 📁 Output: “fruit 1 to fruit 5” list generated automatically 🍎 #JavaScript #FrontendDevelopment #WebDevelopment #LearningJourney #DOM #CodingPractice #DeveloperInProgress #WomenInTech #HTML #JSBeginners #CodeNewbie
To view or add a comment, sign in
-
More from this author
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