JavaScript concatenate string and int | Example code

You can directly add string and number in JavaScript, no need a special method or typecasting. Just use a + (Adds two operands) OR += operator to Concatenate integer variable to a string variable.

+= is Add AND assignment operator, It adds the right operand to the left operand and assigns the result to the left operand

Example of JavaScript concatenate string and int

Here is a code of how to Concatenating numbers and String as a string in JavaScript.

Output:

JavaScript concatenate string and int

Do comment if you have any suggestions and questions on this topic.

Note: All JS Examples codes are tested on the Firefox browser and the Chrome browser.
OS: Windows 10
Code: HTML 5 Version


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.