Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function format(str, ...args){
- return str.split(/(%)/).map(part => (part == "%") ? (args.shift()) : (part)).join("");
- }
- // Example use: format("Hello %, you have visited % times. You are %% of the way there.", username, numVisits, percent, "%")
- // "Hello Troomp, you have visited 420 times. You are 69% of the way there."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement