Skip to content

Instantly share code, notes, and snippets.

@gladchinda
Created July 30, 2018 22:44
Show Gist options
  • Select an option

  • Save gladchinda/dc05300f2c4a019af296708d436abb25 to your computer and use it in GitHub Desktop.

Select an option

Save gladchinda/dc05300f2c4a019af296708d436abb25 to your computer and use it in GitHub Desktop.
const price = 24.99;
const discount = 10;
const quantity = 4;
const totalPrice = quantity * price * (100 - discount) / 100;
// WITHOUT TEMPLATE TAG
console.log(`The price of ${quantity} units of the item on the online store is $${totalPrice}.`);
// The price of 4 units of the item on the online store is $89.964.
// WITH TEMPLATE TAG (pricing)
console.log(pricing`The price of ${quantity} units of the item on the online store is $${totalPrice}.`);
// The price of 4 units of the item on the online store is USD 89.96.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment