While I was working to filter out unnecessary words from the storyWords array using the .filter-method, I at one point tried to use an if-/else-function as callback. The code seemed to work, but when I printed the betterWords array to the console I saw it still containing words I was supposed to have gotten rid of.
I have since looked at the video and I see the benefits of using the .includes-method. But I somehow still wonder why my first amateur try didn’t work out. (I.e., no error code was printed, but “extremely”, “actually” and “literally” still showed up in the filtered array.)
Anyone who can explain why that was?
link to code: https://gist.github.com/27c26496560c513995851614c6950ba1