Skip to content

feat(m4): solution exe 013#2526

Open
lgaleno wants to merge 7 commits into
tomorrowdevs-projects:mainfrom
lgaleno:solution/m4-013-redacting-text-in-a-file
Open

feat(m4): solution exe 013#2526
lgaleno wants to merge 7 commits into
tomorrowdevs-projects:mainfrom
lgaleno:solution/m4-013-redacting-text-in-a-file

Conversation

@lgaleno

@lgaleno lgaleno commented Dec 27, 2022

Copy link
Copy Markdown

No description provided.

const redacted = 'redacted.txt'

//function to read the content of the story
const readStory = story => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

story -> global scope ;-)
const readStory = () => { .....

}

// function to read the content of sesitive words
const readSensitive = sensitive => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sensitive -> global scope ;-)
const readSensitive = () => { .....

@lgaleno lgaleno Jan 23, 2023

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why? it's just in this exercise, because I don't call the fucntion?

return text
}

Promise.all([readStory(story), readSensitive(sensitive)])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Promise.all( [ readStory(), readSensitive() ] )

})
.catch((error) => {
if (error.code === 'ENOENT') {
console.error(`${redacted} file does not exist`)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try renaming sensitive words -> sensitive_words.
Check if the problem prints correctly.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the problem, I will try to fix it by adding a function to read the redacted file and add it to the Promise.all()

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I can optimize the code buy writing only one function to read files and called it 3 times in the Promise.all...
Working in Progress

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants