Created
February 28, 2018 11:07
-
-
Save haingdc/74d971e7b08178cc5c43aab13db6307b to your computer and use it in GitHub Desktop.
A Gentle Introduction to Functional JavaScript: Part 2
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
function t(s,o){ | |
for(var p in o) | |
s=s.replace(new RegExp('{'+p+'}','g'), o[p]); | |
return s; | |
} | |
var data = { name: "July", age: "seventeen" }; | |
t("When {name} was just {age}!", data); | |
// "When July was just seventeen!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment