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

JavaScript Build a Simple Dynamic Site with Node.js Creating a Basic Template Engine in Node.js A Simple Merge Utility

Julianna Kahn
Julianna Kahn
20,702 Points

Error message: Bummer: missing ) after argument list

And I really don't understand what is implied using the % sign.

index.js
var utilities = require("./utilities");

var mailValues = {};

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 :)";
utilities.js
function merge(content, values) {
        content = content.replace("{%"first_name"%}", values[first_name]);
  return content;
}


module.exports.merge = merge;

//mailValues is (emailTemplate, mailValues)
//content = emailTemplate = "Hi %first_name%! Thanks for completing this code challenge :)";
//var mergedContent = utilities.merge(emailTemplate, mailValues);

Hi! Not sure if I am correct, but it looks like you just forgot a parenthesis in the utilities.js snippet.

You typed:

content.replace("{%"first_name"%}"

Maybe it should be this:

content.replace("{%"first_name"%}")          //* See that last element I added... the closing parenthesis.

Like I said, though... I could be wrong. I'm still a newbie with JS but that was something I saw that was in line with their error message. As far as the % symbol goes, google it or go to MDN and search. My guess (without looking it up) is that it is just a way to let the computer know that what is between the % is not actually literal. Since "quotes" tell it to return exactly what is between the quotes, perhaps with the % there, it is being told that something is to be plugged in, within that otherwise literal return sentence.

But I don't know if the code, as a whole, it written correctly or not. You will have to rely on someone who actually knows what they are talking about, to clarify that. Nonetheless, hope I was at least somewhat helpful! Best of luck! :)

2 Answers

Julianna Kahn
Julianna Kahn
20,702 Points

Thanks for trying to help but I still get the same error message with that. But I would still need a ) for the end of the content.replace() statement wouldn't I. Unless I misunderstood your correction.

Yeah... I added it, didn't I? This is actually my first time ever, responding to any question about coding! haha... also, maybe it needs a semicolon!

content.replace("{%"first_name"%}");

I get the actual punctuation confused though, across HTML, CSS & JS.

I have some ebooks, on javascript. I can share them with you, if you think they would help you in understanding overall.

I like to immerse myself in lots of info... because I am kind of a backwards learner. I need to see things taught from many different angles, to actually "get it".

Julianna Kahn
Julianna Kahn
20,702 Points

It's still not working, at least not for me. But thanks for trying to help.