Mini Linter - step 8

Thanks for (re)opening this topic. I am stuck at step 8 too. I finaly started to understand Javascript. until this point. What do you do when you get stuck ? How to stay motivated?

This step is frustrating because I don’t know how to apply without any help. :slightly_frowning_face:

1 Like

Honestly, as a beginner myself, the best piece of advice I could give you (not just for coding, really it can be applied to anything) is just don’t be afraid to get stuck, and then spend time on it. An extract from an article I read really helped me understand why (and trust me when I say it definitely works! I probably spent hours, on each challenge, more than a day on the second one, and while that can seem discouraging, I felt like I was really learning because I truly had to understand what I was typing to actually come up with something) :

“In a variety of brain-mapping studies, scientists discovered that when faced with a problem, the left hemisphere of the brain—the side of the brain typically associated with analytical problem solving—got right to work. However, the tricky problems the scientists developed quickly wore out the left-brain thought process. The subjects became frustrated and complained about the unsolvable problems. This frustration was crucial because it signaled a need for an alternative method, and scientists saw a shift in activity from the left side of the brain to the right side—the more “creative” side—of the brain. Once activity shifted to the right side, subjects often experienced these moments of insight, a flash of activity in the brain resulting in them bolting upright in their chairs as the answer appeared to them. They had to get stumped in order to get creative and solve the problem.”

You should check out the full article here, I personally found it very useful: https://greatergood.berkeley.edu/article/item/five_tips_for_reaching_your_creative_potential

I hope this helped in any way! Don’t get discouraged, we’re learning together :smile: , you can do it! The longer you spend understanding right now, the easier it will be to actual make use of all your knowledge later on :slight_smile:

There’s nothing wrong with seeking the forums/internet for help! It can really be helpful when looking at tackling a problem using different methods. Just make sure you spend as much time as you can trying to solve it yourself first!

Also! Personal preference, but since the lessons teach so much, I find it very useful to use some handwritten notes just to gather what I’ve learnt in one place and have access to it when I’m trying to solve something.

2 Likes

Hi! Thanks for the motivation! You might have hit the nail on the head. I have a brain injury that probably affects the left side of my brain. Your explanation is very helpful. Thanks!

still confuse none code works help!!!

Hi. I came up with a working solution for extra task #3.

// #3

const reallyReplacements = ['truly', 'absolutely', 'certainly'];
const veryReplacements = ['tremendously', 'greatly', 'decidedly'];
const basicallyReplacements = ['essentially', 'fundamentally', 'primarily'];

const replacedWords = [];

const replaceWords = betterWords.forEach((word) => {
  let randomIndex = Math.floor(Math.random()*4);
  if (word === 'really') {
    replacedWords.push(reallyReplacements[randomIndex]);
  } else if (word === 'very') {
    replacedWords.push(veryReplacements[randomIndex]);
  } else if (word === 'basically') {
    replacedWords.push(basicallyReplacements[randomIndex]);
  } else {
    replacedWords.push(word);
  }
})

console.log(replacedWords.join(' '));

However, I’m stuck on #2 of task 8 for a few days now, and I feel really dumb because of that. So far, I stole the .reduce() solution for finding the number of occurrences of each word, from another thread :stuck_out_tongue: . It returns an object, and I don’t know what do do with it (haven’t revised objects yet, and I think I shouldn’t need it for the iterators exercise).
So I have a mental block on the simplest step I think, which is actually finding the most used word.
I would appreciate some guidance, as some solutions from this thread don’t work for me, they just throw type error even after tinkering with the code. Maybe suggestions for a different approach? I really want to get the iterators.

Anyway, thanks to everyone contributiong!

OK, I figured it out after leaving this project for a few days, and learning about objects. It amazes me every time, that the solution is so incredibly simple, yet I wasn’t able to do it.

const frequencyCounter = () => {  
  return zeroPunctuation.reduce((countMap, word) => {
    countMap[word] = ++countMap[word] || 1;
    return countMap;
  }, {}) 
};

const lexicon = frequencyCounter();

const theSearchForTheMostCommonWord = () => {
  let maxCount = 0;
  let maxWord = '';
  for (let key in lexicon) {
    if (lexicon[key] > maxCount) {
      maxCount = lexicon[key];
      maxWord = key;
    }
  }
  console.log(`The most frequent word is "${maxWord}", which was used ${maxCount} times.`);
}
theSearchForTheMostCommonWord();

I hope it helps anybody, who is struggling with this.