DEV Community

Ayobami Ogundiran
Ayobami Ogundiran

Posted on • Updated on

Javascript string concatenation

Concatenation has to do with joining two or more values, usually strings, to create another string as in below.

 let amount = $2000;

 console.log('schoolFees:'+ amount ); // "schoolFeels:$2000"
 console.log("price:" + amount); // "price:$2000"
Enter fullscreen mode Exit fullscreen mode

With this, we have created "schoolFeels:$2000" and "price:$2000" with concatenation.

We can also concatenate in JavaScript using Template literals.

The template literals are a new way to join strings introduced in ES6. Such strings are enclosed by the back-tick – `` and we can easily use variables in template literals by enclosing such variables in a dollar sign and curly braces like this.

`
let name = 'Ayobami';
console.log(`My name is ${name}`) // "My name is Ayobami";
`

Yeah! We have created the string "My name is Ayobami" with template literal concatenation.

Hooooorayyyyyyyyyyyyyy;

We are done with this lesson. In the next, we will discuss data structure, arrays to be specific.

One more thing

Are you having difficulties to learn and understand JavaScript and build projects with it? JavaScript for a Total Novice teaches JavaScript and Project Making Fundamentals with simple illustrations and examples that make everything so easy. You can now handle any difficult projects without fear.

Don't trust me, get a free previous to judge by yourself: https://bit.ly/3o3TMyg

Top comments (0)