Grammar Checker project

Hello!
I’m working on the Grammar Checker and am stuck on step 6 where I’m asked to filter out the unnecessary work ‘Literally’. I followed the walkthrough video but my code isn’t working. In the video the developer coded the following:
storyWords = storyWords.filter((word) => {
return word !== unnecessaryWord;
})
I’ve checked over my code a few times but still don’t see what is different between my code and the walkthrough code. I’ve included my link at the bottom. If anyone would be willing to check it out I’d appreciate it.
Samantha

https://www.codecademy.com/workspaces/62728c3f5d5589696db5b8f4

Well I’m not sure what I did differently but after deleting my code and rewriting it the code is now working :slight_smile:

1 Like

(post deleted by author)

This is what I got, and it went just fine. You forgot to add the if statement and the variable word does not need ( ) around itself.

storyWords = storyWords.filter(word => {
  if(word != unnecessaryWord) {
    return word;
  }
});
1 Like

Hello, can anyone explain why in step 11 or Grammar Checker project we use “&&” before console.log?
so the code looks like this:
word.length > 10 && console.log(word)

I dont understand why there’s “&&”?

Hi Java!

I’m not 100% sure this is correct but I believe the developer in the video said he used the && (which is a true && true logical operator) along with the console.log to show the one word that was greater that 10 letters. I hope this helps :blush:

oh well now it starts to make sense to me. Thank you very much!

1 Like

Hi, I’m still stuck on step 11 for Grammer Checker project. I don’t understand why we have to use the && in front of console.log so the code looks like this:

storyWords.forEach((word) => {
word.length > 10 && console.log(word)
})

I tried removing the && and separating the console.log from the function body but I just keep getting undefined instead of the word that’s greater than 10 letters. Does anyone know why?

let longWord = storyWords.forEach((word) => {
return word.length > 10
})
console.log(longWord)

Prints: undefined

So one developer explained to me that it could have been rewritten like this :
If (word > 10) return console.log(word)

it’s the same

I see so the if statement can work in this case. It looks like if I removed the return keyword it also works. Thank you very much!!

Hi,
I am having the same problem. I have checked my code with the video example and I cannot see any difference except that my code is not deleting the “literally” word " from the original text:
https://www.codecademy.com/workspaces/65f84024ccf5a2c0fbe4e1f1
I also tried with the if statement and it didn’t work either. Could anyone help, please?
Thanks!