You already learned how to do comments in HTML and CSS if you did those tutorials.

Comments in JavaScript can be done in two ways one of which is the same as CSS commenting

Multi-line comments

Open jsfunction.html and save it as jscomments.html.  You should have a very simple function in it.  Add these four lines just before the function but inside the script element:

/* this is a comment which continues until the closing marker meaning you can continue it on a new line.
It is useful when describing the purpose of large blocks of code such as functions.
This function says hello.
*/

In your editor those lines should be clearly coloured to show that they are not code.  Run the page and it works just the same as before because the new text is for human use and is completely ignored by the browser.

Using comments to explain your code is essential as then other people will find it easier to understand.  If you come back to the code after years it will also help you to remember how it works.  You can also use it to make notes to fix small problems which you know about but do not have time to do now.

Single line comments

If you just want to make a quick note you can put a single line comment.  Make a new blank line just before the alert line.  Put this there:

// alert is a built in function which displays messages

Commenting out code

Sometimes you will want to put comment markers around actual PHP code to stop it from working.  Often this is during testing but you will see another use very soon.

Place /* before the alert line and */ after it.  Try the page and there is no message.  You can also do the same by using // if you are commenting out just one line.