Skip to content

Instantly share code, notes, and snippets.

@rishisidhu
Created July 10, 2020 11:25
Show Gist options
  • Save rishisidhu/16db3a2df8f69dc85c9fd3ee060983bd to your computer and use it in GitHub Desktop.
Save rishisidhu/16db3a2df8f69dc85c9fd3ee060983bd to your computer and use it in GitHub Desktop.
Modern JS ES6+ features - Template Literals
const Currency1 = "Dollars";
const Currency2 = "Rupees";
const exchange_rate = 72;
news_string = "Today 100 " + Currency1 + " are trading for " + exchange_rate * 100 + " " + Currency2;
//The normal way
console.log(news_string);
//The template literal way
news_string_tl = `Today 100 ${Currency1} are trading for ${exchange_rate * 100} ${Currency2}`;
console.log(news_string_tl);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment