Skip to content

[zh-CN] Misleading comments in string concatenation examples (Incorrect commas) #1940

Open

Description

@taneightseven

Description:
Describe the bug
In the Chinese translation of the JavaScript basics lesson (String Formatting section), the comments in all three code examples are identical (//你好,世界!), which is highly misleading because the actual output of the first two lines does not contain a comma.

To Reproduce
Steps to reproduce the behavior:

Go to the lesson file: [File Path / URL]

Look at the code snippet under "字符串格式化":
let myString1 = "Hello";
let myString2 = "World";

myString1 + myString2 + "!"; //你好,世界!
myString1 + " " + myString2 + "!"; //你好,世界!
myString1 + ", " + myString2 + "!"; //你好,世界!

3.Analyze the actual outputs vs the comments:

Line 1: myString1 + myString2 + "!" outputs HelloWorld!. The comment says 你好,世界! (contains a comma, incorrect).

Line 2: myString1 + " " + myString2 + "!" outputs Hello World! (only a space). The comment says 你好,世界! (contains a comma, incorrect).

Line 3: myString1 + ", " + myString2 + "!" outputs Hello, World!. The comment 你好,世界! is a loose translation but acceptable here.

Expected behavior
The comments should accurately reflect the actual output of the code. Because the first two lines do not add a comma, beginners will be confused when the output doesn't match the "中文意译" in the comment.

Suggested fix
Update the comments to strictly match the code output. For example:

myString1 + myString2 + "!"; // HelloWorld! (or 你好世界!without comma)
myString1 + " " + myString2 + "!"; // Hello World! (or 你好 世界!without comma)
myString1 + ", " + myString2 + "!"; // Hello, World! (or 你好,世界!with comma)
Screenshots

Image

Additional context
This is a common issue in translated documentation. The translator translated the result into natural Chinese, but forgot to update the comment for the first two examples where the code explicitly concatenates without a comma. This causes a mismatch between the JS logic and the expected output for beginners.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions