Skip to content

Latest commit

 

History

History
13 lines (10 loc) · 450 Bytes

string_interpolation.MD

File metadata and controls

13 lines (10 loc) · 450 Bytes

#String Interpolation

In ES6, for string concatenation, we can put our string within single backticks and then the objects we want to interpolate within ${}.

##Example:

var bicycle = { brand: "trek" }
var driveTrain = { cassette: 9, chainrings: 2, price: 100 }
message = `Your ${bicycle.brand} bike,
has cassette of ${driveTrain.cassette} rings and ${driveTrain.chainrings} chainrings for
a total cost of ${driveTrain.price} dollars.`