How to concatenate strings in JavaScript

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

  • diagram

To view or add a comment, sign in

Explore content categories