Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Vic Mercier
3,276 PointsTemplate literal
Is it correct if I do that: const alertName = name=>alert(alertName(${name}));
And: function getName(name){ return name; } document.write('My name is ${getName("victor")');
1 Answer
Christopher Debove
Courses Plus Student 18,373 PointsLiteral templating can only be used with the string interpolation (` backtick) Don't forget to close the curly braces.
So to repeat your codes:
const alertName = alert(`${name}`); // Not necessary, and cannot alert the function your calling, it will be called infinitely
function getName(name) {
return name;
}
document.write(`My name is ${getName("victor")}`);