2. for (var key in values) { 3. string = string.replace(new RegExp("\{" + key + "}"), values[key]); 4. } 5. return string; 6. } 7. 8. test("basics", function() { 9. var values = { 10. name: "World" 11. }; 12. equal( format("Hello, {name}", values), "Hello, World", "single use" ); 13. equal( format("Hello, {name}, how is {name} today?", values), 14. "Hello, World, how is World today?", "multiple" ); 15. }); Java script source