Rookie Question: //Output

Tell us what’s happening:

So, either I missed something or I am slow to pick up on this bit.
When you have // then some words, this is just to make note of what the code is supposed to be doing, right?


//Outputs a possible answer to life

Therefore, my comment could just say something like this? Is there a standard or preferred way to make comments?

//Sum of numbers
//sum of input

Your code so far

// Example
function ourFunctionWithArgs(a, b) {
  console.log(a + b);
ourFunctionWithArgs(4, -2); // Outputs 2

// Only change code below this line.

function functionWithArgs (a,b) {
functionWithArgs(55,5); //Outputs 

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0.3 Safari/605.1.15.

Link to the challenge:


// is used for commenting, its not to describe what the code does, But the comments are used to keep whatever notes you want to read when you go through the code again. There are no standard way of commenting. But there is a tip I would like to share

// This is a Single Line comment 

This is a multi-line comment.
you can add as many line you want
and keep in mind to end the comment as well

Hope this helps

1 Like

You can do comments to remind you or anyone else reading your code what particular things do, outcomes,why… basically if you look back at code that you’ve commented you’ll figure out what it all does a lot quicker

1 Like

Thanks! That does help. Come to think of it, I guess this was introduced earlier in the lessons. I think I was just now making the connection. I think I was just looking for a practical application of the note.

1 Like

That helps.

I guess I was caught up on the fact that the curriculum keeps commenting on the output of the code.

To be fair, you can do that (and when things get complicated it helps when you have other devs you work with). Comments are essential for sanity in large programs…people will tell you they are not but when you get stuck trying to fix a million line project with no comments you will think otherwise

I also use it to scare people

//Do not change the following code with out contacting If you do not notify me, I will find your desk and cover it with frosting.

I may have strong opinions on comments :smiley:


Need more data…if its cream cheese or chocolate frosting…I might be inclined to change all the code. :crazy_face:

But yeah, its good to use descriptive variable names and write readable code so that you don’t need to comment on what every single thing does… but for sure there will be times when a piece of code is kind of tricky and the comment helps others or future you understand why you wrote it that way.

I tend to write //TODO comments on code with info on what I want to do with it at some point. I also write // HALP comments when I find a part of my code that’s messing stuff up, but I dont know why and need to do some research on it.


Oh yes. I write lots of things like this:

// I know this is looping but the API doesn’t have any fields for what’s looping from, where is it finding the data? Who did this to me? What is that last variable that seems to be pointing to itself?


I totally want to work with you, your comments would have me in stitches :rofl:


Love it!

I imagine I would use comments for exactly this. I can imagine using it to comment that I was still working on something.

If it’s cream cheese icing, I AM going to mess with the code. I promise.

1 Like

I tend to use a few conventions, some of which are handy for marking up other peoples code when I’m maintaining it.

// BUG #bugid
// TODO (obvious)
// WRITEME (incomplete implementations)
// DOCUMENT (no docs) 
// HUH (obfuscated code or docs)
// WTF (baffling behavior)
// XXX (miscellaneous thing to call out)

Most of these “flag” comments have a short summary afterward on the same line, like
// TODO use the Foo::Frobnicate library instead of frobbing by hand

To find all these comments, I just do ag '// [A-Z]{3,}'
(ag is a much more powerful grep, and works identically on all platforms)


@chuckadams, those all make sense and I imagine I will adopt something similar.

Though, you’ve lost me on this bit. I’m sure I’ll learn that bit eventually.

To find all these comments, I just do ag ‘// [A-Z]{3,}’
(ag is a much more powerful grep, and works identically on all platforms)