Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Suggestions for Code Correction in 'File Read and Write' and Update on 'Class and Object' Section #40

Closed
@baekilda

Description

Hello!
First of all, I'd like to express my gratitude for your work. This book has been instrumental in helping me quickly understand Python, and for that, I thank you!

I have a few modest suggestions regarding some parts of the book:

  1. In the section File Read and Write, the JavaScript example code uses the return keyword:
import fs from 'fs';
const data = fs.readFileSync('books.txt', 'utf8');
const books = data.split('\n');
const classics = ['The Story of the Stone', 'Journey to the West', 'Water Margin', 'Romance of the Three Kingdoms'];
const missingClassics = classics.filter(classic => !books.includes(classic));
if (missingClassics.length === 0) {
 console.log('The file already contains the four great classical novels of China.');
 return; // <- here
}
// ...

However, the return keyword must be used within a function body, while the provided code is not inside one. I believe it might be better to use if-else structure, similar to the Python example shown.

  1. In the Class and Object section, the first tip states, "The static keyword in the class is not native to JavaScript, but a feature provided by TypeScript." However, considering that class static fields are now included in ES2022 and supported by most runtimes, I suggest that the part about the static keyword could be removed.

If you find these suggestions helpful, I would be happy to contribute a Pull Request to implement these changes. Please feel free to let me know.

Thank you again for your fantastic work :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /