DEV Community

loading...

Discussion on: How to Create Multi-Line String with Template Literals

Collapse
flrnd profile image
Florian Rand

Another good addition to template literals is writing more readable code, for example:

const name = 'Peter'
const age = 35

//instead of the classic concatenation
console.log(name + " is only " + age + " old!")

//we can write something like this:
console.log(`${name} is only ${age} old!`)
Collapse
samanthaming profile image
Samantha Ming Author

Totally! String interpolation is probably one of my most used ES6 feature πŸ’―

Collapse
flrnd profile image
Florian Rand

Same here! Btw I forgot to mention great article! (Concentrated writing the example totally forgot about being polite 😁)

Thread Thread
samanthaming profile image
Samantha Ming Author

You’re welcome! Btw, thanks for jumping back and leaving this kind comment 😊 You’re making this community really nice to a part of πŸ’›

Collapse
qcgm1978 profile image
Youth

It also works

console.log(`%s is only %d old!`,name,age)