Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,701 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,701 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,701 Points

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