Commenting your code - ThePix/QuestJS GitHub Wiki

It is often a good idea to add comments to your code so that when you come back to it three months later you can remember what you did and why you did it.

JavaScript - and hence QuestJS - support two types of comments.

Line comments

Line comments start with two slashes, and continue to the end of the line.

  player.score += 5  // he did well, so increase the score

Multi-line comments

Multi-line comments start with a slash and an asterisk, and continue until the reverse, an asterisk and a slash.

/*
This function does some useful stuff
*/
function doStuff(arg1, arg2) {
  ...
}

Despite the name, multi-line comments can be used on a single line, and even in the middle of a line. In this example, a multi-line comment has been used to hide the second parameter in the function call from Quest.

doStuff("lounge"/*, "A curious room"*/)

Comments when debugging

This illustrates an important use of comments - to temporarily hide code while you try to debug. If something is interfering with your system, try commenting out blocks of code - usually whole objects - to be sure they are not the problem.