Created
January 8, 2021 18:53
-
-
Save jherr/ba93c905b5f2e30cd4c8db4f3f9f747e 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 inject = (str, obj) => str.replace(/\${(.*?)}/g, (_, g) => obj[g]); | |
console.log( | |
inject("Hello ${name}, Bye ${name2}", { name: "Jack", name2: "Dave" }) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment