Skip to content

Commit ea64746

Browse files
committed
Make tagged template strings solution a bit more efficient.
See #15.
1 parent 5abf344 commit ea64746

File tree

1 file changed

+1
-3
lines changed
  • lib/exercises/tagged_template_strings/solution

1 file changed

+1
-3
lines changed

lib/exercises/tagged_template_strings/solution/solution.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
console.log(html`<b>${process.argv[2]} says</b>: "${process.argv[3]}"`);
22

33
function html(pieces, ...substitutions) {
4-
substitutions = substitutions.map(escape);
5-
64
var result = pieces[0];
75
for (var i = 0; i < substitutions.length; ++i) {
8-
result += substitutions[i] + pieces[i + 1];
6+
result += escape(substitutions[i]) + pieces[i + 1];
97
}
108

119
return result;

0 commit comments

Comments
 (0)