Last active
February 4, 2020 12:02
-
-
Save gladchinda/6009b54a6cbdbeca47e7830b601960a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const item = { | |
quantity: 4, | |
unitPrice: 49.99, | |
discount: 0.24, | |
get price () { return (this.quantity * this.unitPrice * (1 - this.discount)).toFixed(2) } | |
}; | |
// String concatenation | |
const pricing = 'The total price of ' + item.quantity + ' units of this item is $' + item.price + '.'; | |
console.log(pricing); // "The total price of 4 units of this item is $151.97." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const item = { | |
quantity: 4, | |
unitPrice: 49.99, | |
discount: 0.24, | |
get price () { return (this.quantity * this.unitPrice * (1 - this.discount)).toFixed(2) } | |
}; | |
// String substitution with template literal | |
const pricing = `The total price of ${item.quantity} units of this item is $${item.price}.`; | |
console.log(pricing); // "The total price of 4 units of this item is $151.97." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment