2018-09-30 23:01:58 +01:00
---
id: bd7123c9c441eddfaeb4bdef
title: Comment Your JavaScript Code
challengeType: 1
2019-02-14 12:24:02 -05:00
videoUrl: 'https://scrimba.com/c/c7ynnTp'
2019-07-31 11:32:23 -07:00
forumTopicId: 16783
2018-09-30 23:01:58 +01:00
---
2020-11-27 19:02:05 +01:00
# --description--
2018-09-30 23:01:58 +01:00
Comments are lines of code that JavaScript will intentionally ignore. Comments are a great way to leave notes to yourself and to other people who will later need to figure out what that code does.
2020-11-27 19:02:05 +01:00
2018-09-30 23:01:58 +01:00
There are two ways to write comments in JavaScript:
2020-11-27 19:02:05 +01:00
Using `//` will tell JavaScript to ignore the remainder of the text on the current line:
2019-05-17 06:20:30 -07:00
```js
// This is an in-line comment.
```
2020-11-27 19:02:05 +01:00
You can make a multi-line comment beginning with `/*` and ending with `*/` :
2019-05-17 06:20:30 -07:00
```js
/* This is a
multi-line comment */
```
2020-11-27 19:02:05 +01:00
**Best Practice**
As you write code, you should regularly add comments to clarify the function of parts of your code. Good commenting can help communicate the intent of your code—both for others *and* for your future self.
# --instructions--
2018-09-30 23:01:58 +01:00
Try creating one of each type of comment.
2020-11-27 19:02:05 +01:00
# --hints--
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
You should create a `//` style comment that contains at least five letters.
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
```js
assert(code.match(/(\/\/)...../g));
2018-09-30 23:01:58 +01:00
```
2020-11-27 19:02:05 +01:00
You should create a `/* */` style comment that contains at least five letters.
2018-09-30 23:01:58 +01:00
```js
2020-11-27 19:02:05 +01:00
assert(code.match(/(\/\*)([^\/]{5,})(?=\*\/)/gm));
2018-09-30 23:01:58 +01:00
```
2020-11-27 19:02:05 +01:00
# --seed--
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
## --seed-contents--
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
```js
```
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
# --solutions--
2018-09-30 23:01:58 +01:00
```js
// Fake Comment
/* Another Comment */
```