Comments
Part of the Fundamentals section of Coddy's Solidity journey. Lesson 3 of 53.
Comments are notes for people reading your code. Ordinary comments are ignored when the program runs.
Start a single-line comment with //. Everything after it, up to the end of that line, is a comment:
// Explain the greeting
console.log("Hello!");A comment can also follow a statement on the same line:
console.log("Hello!"); // Display a greetingUse /* and */ for a comment that spans several lines. Always include the closing marker:
/* This note spans
two lines. */
console.log("Ready!");Commenting out a statement disables it without deleting it. Here, only the second message appears:
// console.log("Hidden");
console.log("Visible");Challenge
EasyFix the provided code so that only Hello, Solidity! is printed. Add // at the start of the line that prints Goodbye!. Keep that line as a comment, and leave the greeting line unchanged.
Use console.log for the requested output. Print only the requested values, one per line, with no extra labels unless the task specifies them.
Try it yourself
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
import "forge-std/console.sol";
contract Main {
function main() external view {
console.log("Goodbye!");
console.log("Hello, Solidity!");
}
}This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Fundamentals
Practice on your own: Solidity playground