Categories
JavaScript Answers

How to concatenate two numbers in JavaScript?

Spread the love

Sometimes, we want to concatenate two numbers in JavaScript.

In this article, we’ll look at how to concatenate two numbers in JavaScript.

How to concatenate two numbers in JavaScript?

To concatenate two numbers in JavaScript, we can use template literals.

For instance, we write

const a = 5;
const b = 6;
const numbersAsString = `${a}${b}`;

console.log(numbersAsString);

to interpolate the values a and b into the numersAsString template literal.

Then numbersAsString is '56'.

Conclusion

To concatenate two numbers in JavaScript, we can use template literals.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *