Hi Friends đź‘‹,

Welcome To Infinitbility! ❤️

Today, we are going to learn concat two strings in javascript, here we will use the plus ( + ) operator to join both strings, we will also see append strings with separators like comma (,).

The plus operator basically used for adding but if you use this operator between strings it will concat string.

Well, let’s start today’s tutorial How to concat two strings in javascript?

let’s plan what we are going to do.

  1. create two string variable with some data
  2. create function and write logic to concat
  3. use function to concat string with separator
// create two string variable with some data
const str1 = "infinitbility";
const str2 = "aguidehub";

// create function and write logic to concat
function concat(str1, str2) {
  return str1 + ',' + str2;
}

// use function to concat string with seprator
concat(str1, str2)

When you run the above code, you will both string join to each other with comma separator.

let’s check the output.

javascript, concat two strings example
javascript, concat two strings example

I hope it’s help you, All the best 👍.