From b02b3f51acc5c9c85487b01847bf20b56bb59356 Mon Sep 17 00:00:00 2001 From: SamBSalgado Date: Fri, 27 Jun 2025 12:22:06 -0600 Subject: [PATCH 1/4] Improve sentence clarity in comments section --- en/basics/comments.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/en/basics/comments.md b/en/basics/comments.md index 9d871e93..517dbd4c 100644 --- a/en/basics/comments.md +++ b/en/basics/comments.md @@ -6,7 +6,7 @@ description: Comments are used to mark annotations for other programmers or smal # Comments -Comments are statements that will not be executed by the interpreter, comments are used to mark annotations for other programmers or small descriptions of what code does, thus making it easier for others to understand what your code does. They are also used to temporarily disable code without affecting the program control flow. +Comments are statements that will not be executed by the interpreter. They are used to mark annotations for other programmers or small descriptions of what code does, thus making it easier for others to understand what your code does. They are also used to temporarily disable code without affecting the program control flow. In JavaScript, comments can be written in two different ways: From 5feeb509a7ebb83e707d01e2a0f553c26bde05e5 Mon Sep 17 00:00:00 2001 From: SamBSalgado Date: Fri, 27 Jun 2025 12:51:39 -0600 Subject: [PATCH 2/4] Apply formatting structure suggested in issue #79 --- en/basics/comments.md | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/en/basics/comments.md b/en/basics/comments.md index 517dbd4c..f7f3e286 100644 --- a/en/basics/comments.md +++ b/en/basics/comments.md @@ -8,23 +8,49 @@ description: Comments are used to mark annotations for other programmers or smal Comments are statements that will not be executed by the interpreter. They are used to mark annotations for other programmers or small descriptions of what code does, thus making it easier for others to understand what your code does. They are also used to temporarily disable code without affecting the program control flow. -In JavaScript, comments can be written in two different ways: +## Types of Comments -* **Single-line comments**: It starts with two forward slashes (`//`) and continue until the end of the line. Anything following the slashes is ignored by the JavaScript interpreter. For example: +### Single Line Comments + +Single-line comments start with two forward slashes (`//`) and continue until the end of the line. Anything following the slashes is ignored by the JavaScript interpreter. ```javascript // This is a comment, it will be ignored by the interpreter -let a = "this is a variable defined in a statement"; +let a = "This is a variable"; ``` -* **Multi-line comments**: It starts with a forward slash and an asterisk (`/*`) and end with an asterisk and a forward slash (`*/`). Anything between the opening and closing markers is ignored by the JavaScript interpreter. For example: +You can also use them at the end of a line: + +```javascript +let b = 5; // This is also a valid single-line comment +``` + +### Multi-line Comments +Multi-line comments start with /* and end with */. Everything in between is ignored. ```javascript /* -This is a multi-line comment, -it will be ignored by the interpreter + This is a multi-line comment. + You can use it to explain more complex logic + or block out code temporarily. */ -let a = "this is a variable defined in a statement"; +let x = 10; +``` + +### Real-life Examples of Comments +```javascript +// Change heading: +document.getElementById("myH").innerHTML = "My First Page"; + +// Change paragraph: +document.getElementById("myP").innerHTML = "My first paragraph."; +``` + +They are also useful for debugging purposes: + +```javascript +let total = 0; +// total = calculateTotal(items); // Temporarily disabled during testing ``` Including comments in code is essential for maintaining code quality, enabling collaboration, and simplifying the debugging process. By providing context and explanations for various parts of the program, comments make it easier to understand the code in the future. Therefore, it is considered a beneficial practice to include comments in code. \ No newline at end of file From 0e85c99d9390d40e5e6519d8826c15e59b4b208f Mon Sep 17 00:00:00 2001 From: SamBSalgado Date: Fri, 27 Jun 2025 13:20:05 -0600 Subject: [PATCH 3/4] Add two extra real-life examples --- en/basics/comments.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/en/basics/comments.md b/en/basics/comments.md index f7f3e286..a1d36a15 100644 --- a/en/basics/comments.md +++ b/en/basics/comments.md @@ -46,6 +46,17 @@ document.getElementById("myH").innerHTML = "My First Page"; document.getElementById("myP").innerHTML = "My first paragraph."; ``` +```javascript +/* + Temporarily disabled welcome message while testing new UI flow. +*/ + +/* +document.getElementById("myH").innerHTML = "Welcome back!"; +document.getElementById("myP").innerHTML = "We're glad to see you again."; +*/ +``` + They are also useful for debugging purposes: ```javascript @@ -53,4 +64,17 @@ let total = 0; // total = calculateTotal(items); // Temporarily disabled during testing ``` +```javascript +/* + Debugging logs for login issue + Commented out after issue was resolved +*/ + +/* +console.log("User data:", user); +console.log("Auth token:", token); +console.log("Response from API:", response); +*/ +``` + Including comments in code is essential for maintaining code quality, enabling collaboration, and simplifying the debugging process. By providing context and explanations for various parts of the program, comments make it easier to understand the code in the future. Therefore, it is considered a beneficial practice to include comments in code. \ No newline at end of file From af4f784a62b26e9e74d1b4e20e751224cf4302f6 Mon Sep 17 00:00:00 2001 From: SamBSalgado Date: Fri, 27 Jun 2025 13:33:55 -0600 Subject: [PATCH 4/4] Fix incorrect italics caused by asterisks in comment example --- en/basics/comments.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/en/basics/comments.md b/en/basics/comments.md index a1d36a15..700f3489 100644 --- a/en/basics/comments.md +++ b/en/basics/comments.md @@ -26,7 +26,7 @@ let b = 5; // This is also a valid single-line comment ``` ### Multi-line Comments -Multi-line comments start with /* and end with */. Everything in between is ignored. +Multi-line comments start with `/*` and end with `*/`. Everything in between is ignored. ```javascript /*