join two strings in typescript

To join two strings in Typescript, you can simply use the + operator or use template literals.

Method 1: Using the + operator

index.ts
let string1 = "Hello";
let string2 = "World";
let result = string1 + " " + string2;
console.log(result); // Output: "Hello World"
130 chars
5 lines

Method 2: Using Template literals

index.ts
let string1 = "Hello";
let string2 = "World";
let result = `${string1} ${string2}`;
console.log(result); // Output: "Hello World"
130 chars
5 lines

Both methods concatenate the two strings and produce the same output.

gistlibby LogSnag