DEV Community

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

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

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)