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 trialNikolaj Nielsen
1,251 PointsI'm trying to solve this challenge, but no matter what I do I always get it wrong!!
I simply cannot see what I'm doing wrong!! This works perfectly on another project I'm doing
var utilities = require("./utilities");
var mailValues = {
first_name: ""
};
mailValues.first_name = "Janet";
var emailTemplate = "Hi %first_name%! Thanks for completing this code challenge :)";
var mergedContent = utilities.merge(emailTemplate, mailValues);
//mergedContent === "Hi Janet! Thanks for completing this code challenge :)";
function merge(content, values) {
for (var key in values)
{
content = content.replace("%first_name%", values[key]);
}
return content;
}
module.exports.merge = merge;
1 Answer
Steven Parker
231,248 PointsYou're really close, here's a couple of hints:
- don't modify index.js, your changes only go in utilities.js in the merge function
- your merge routine should replace any and all keys, not just "first_name"
I'm betting you can get it now without an explicit spoiler.
Nikolaj Nielsen
1,251 PointsNikolaj Nielsen
1,251 PointsThanks Steven!! I had a feeling it was quite simple!