String concatenation

JavaScript tutorial: String concatenation

/**
 * Simple way to concatination two string 
 * we have to use + to concatinate two string
 */

 console.log("My name is " + "Riaj Ahmed");

 // We can do it useing variable on one side.
 var name = "Riaj Ahmed";
 console.log("My name is " + name);

 // We can use concatination useing variable on two  side of +
 var firsName = "Riaj";
 var lastName = "Ahmed";
 console.log("Full Name:" + "   " + firsName + lastName); // For blanck space "     " can be used.

 // Other use of concantrate
 var num1 = 30;
 var num2 = 40;
 console.log( "First Number is " + num1 + " and Second Number is " + num2 + ".");

 // Concatenate with function
 var text1 = "Honesty ";
 var text2 = "is the best policy.";
 var text = text1.concat(text2);
 console.log(text);

Leave a Reply

affiliate money machine

Hey, don't miss
Free
‘Digital Marketing’ E-book

Affiliate Money Machine

Sign up for our newsletter with the best digital marketing tools and affairs inspirations.