Having trouble with Word Blanks

Tell us what’s happening:
The Issue i am having is that there is another requirement as follows that i am not satisfying causing me not ot pass this challenge but i can’t figure out what it is that i have to do

Here is the requirement:
wordBlanks("cat", "little", "hit", "slowly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).

When i use these words, then the other requirement with the words ( dog, big, ran, quickly) is not satisfied.

Your code so far


function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  // Your code below this line
  var result = "We saw a " + "dog" + " that was " + "big" + " and " + "ran" + " away quickly";

  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/word-blanks

You hard coded the result variable this is why its not working.
You have to use the function arguments like so:


var result = “My " +myNoun+” ,that was " +myAdjective +" “+myVerb +” away “+myAdverb +” ."

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

Thank you for understanding.

If you don’t want to see directly the solution…

If you have a function greetings("Lorie") which returns a string "Hi, my name is Lorie!", and you want it to be reusable, in the way that it works also for greetings("Bob"), greetings("James"), greetings("Julia"), you need to have a string with placeholders. Something like

function greetings(name) {
   return "Hi, my name is " + name + "!";
}
1 Like

Oh yes I am very sorry for that ! Next time I will only post hints instead