Mini Linter Step 6 function help


I’ve searched the forum for this and have been unable to come up with the answer, unfortunately.

On the mini-linter project I’m struggling to come up with a function that logs all of the values, but doesn’t print undefined to the console. My code is as so so far:

let story = 'Last weekend, I took literally the most beautiful bike ride of my life. The route is called "The 9W to Nyack" and it actually stretches all the way from Riverside Park in Manhattan to South Nyack, New Jersey. It\'s really an adventure from beginning to end! It is a 48 mile loop and it basically took me an entire day. I stopped at Riverbank State Park to take some extremely artsy photos. It was a short stop, though, because I had a really long way left to go. After a quick photo op at the very popular Little Red Lighthouse, I began my trek across the George Washington Bridge into New Jersey.  The GW is actually very long - 4,760 feet! I was already very tired by the time I got to the other side.  An hour later, I reached Greenbrook Nature Sanctuary, an extremely beautiful park along the coast of the Hudson.  Something that was very surprising to me was that near the end of the route you actually cross back into New York! At this point, you are very close to the end.';

let overusedWords = ['really', 'very', 'basically'];

let unnecessaryWords = ['extremely', 'literally', 'actually' ];

let storyWords = story.split(' ');

let betterWords = storyWords.filter(function(word) {
                  return !unnecessaryWords.includes(word)

let reallyCount = 0;
let veryCount = 0;
let basicallyCount = 0;

storyWords.forEach(word => {
  if (word == 'really') {
  reallyCount += 1}
 else if 
  (word == 'very') {
   veryCount += 1}
  else if 
  (word == 'basically') {
   basicallyCount += 1}

let sentenceCount = 0;

storyWords.forEach(word => {
  if (word[word.length-1] === '.' || word[word.length-1] === '!') {
    sentenceCount += 1;

const paragraphStats = () => {
  console.log('Your paragraph has ' + sentenceCount + ' sentences');
 console.log('All of these sentences consist of ' + betterWords.length + ' words');
 console.log('You used really ' + reallyCount + ' times');
 console.log('You used very ' + veryCount + ' times');
 console.log('You used basically ' + basicallyCount + ' times');


My paragraphStats function when logged out returns:

Your paragraph has 12 sentences
All of these sentences consist of 182 words
You used really 2 times
You used very 5 times
You used basically 1 times

Can someone please help me understand where the undefined is coming from and how to remove it? Many thanks.

1 Like

It’s coming from the last statement. paragraphStats does not return anything so undefined is what the caller sees, and in that case, logs it.

Try just calling your function and let it do the logging, as planned.

1 Like

Ahh, you are totally correct sir. Thanks for the help!