OneBite.Dev - Coding blog in a bite size

combine two strings in Javascript

Code snippet on how to combine two strings in Javascript

let string1 = 'Hello';
let string2 = 'World';

let combineString = `${string1} ${string2}`;
console.log(combineString); // Output: "Hello World"

This code uses two string variables called string1 and string2. Then it combines them using the string interpolation syntax, which wraps the strings in backticks () and uses ${} to add the variables into the string. Finally, it logs the combined string to the console using console.log()`, which displays the output as “Hello World”.

javascript