Learn
Hello World
Comments

Our own code can quickly become difficult to understand when we return to itβ€”sometimes only a few hours later! For this reason, it’s often useful to leave a note or reminder in our code for our future selves or other developers.

In order to tell the computer that some of the text in our program is only meant for notes (and shouldn’t be executed), we can designate parts of our code as comments. Comments can explain what the code is doing, leave instructions for developers using the code, or add any other useful annotations.

There are two types of code comments in Emojicode:

A single line comment will comment out a single line and is denoted by πŸ’­ preceding it:

πŸ’­ Prints "hi" πŸ˜€ πŸ”€hiπŸ”€β—οΈ

A πŸ’­ comments out any code that follows it (until the end of the line), so you can also use one after a line of code:

πŸ˜€ πŸ”€hiπŸ”€β—οΈ πŸ’­ Prints "hi"

A multiline comment will comment out multiple lines and is denoted by πŸ’­πŸ”œ to begin the comment, and πŸ”šπŸ’­ to end the comment:

πŸ’­πŸ”œ This is all commented out. None of this is going to run! πŸ”šπŸ’­

Let’s try writing two comments.

Instructions

1.

Somewhere in the program, add a single line comment with today’s date.

2.

Add a multiline comment that explains how you are feeling.

Folder Icon

Take this course for free

Already have an account?