DEV Community

Ayobami Ogundiran
Ayobami Ogundiran

Posted on • Edited on

2

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

AWS Q Developer image

Your AI Code Assistant

Ask anything about your entire project, code and get answers and even architecture diagrams. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Start free in your IDE

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay