Skip to content

Latest commit

 

History

History
21 lines (14 loc) · 540 Bytes

string-interpolation.md

File metadata and controls

21 lines (14 loc) · 540 Bytes

String Interpolation

You can use string interpolation to insert the value of a variable into the middle of a string.

Examples

Adding strings

const name = 'Megan';
console.log('Hi! My name is ' + name); // 'Hi! My name is Megan'

Using ES6 template strings

Starting with ES6, you can do string interpolation using template strings. Use backticks (`) instead of single quotes (') to wrap your string.

const name = 'Megan';
console.log(`Hi! My name is ${name}`); // 'Hi! My name is Megan'