Word Blanks - help me with this challenge

Tell us what’s happening:
In this challenge, we provide you with a noun, a verb, an adjective and an adverb. You need to form a complete sentence using words of your choice, along with the words we provide.

You will need to use the string concatenation operator + to build a new string, using the provided variables: myNoun , myAdjective , myVerb , and myAdverb . You will then assign the formed string to the result variable.

You will also need to account for spaces in your string, so that the final sentence has spaces between all the words. The result should be a complete sentence.

Your code so far


function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  // Your code below this line
  var result = "A big dog ran quickly";

  // Your code above this line
  return result;
}

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; rv:64.0) Gecko/20100101 Firefox/64.0.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/word-blanks
And this is the criteria i need to meet
wordBlanks("","","","") should return a string.

wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).

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).

I think you missunderstood the challenge. You shouldn’t directly write out a string and return it, you need to use the variables passed in as parameters in the function.

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb)

You will need to use the string concatenation operator + to build a new string, using the provided variables: myNoun , myAdjective , myVerb , and myAdverb . You will then assign the formed string to the result variable.

If you take a look at how the function is called
wordBlanks("cat", "big", "ran", "quickly");
cat will be equal to myNoun.
big will be equal to myAdjective
ran will be equal to myVerb
quickly will be equal to myAdverb.

If you don’t use the variables, then you hardcode in the string and the function will always return the same string, no matter what words you pass in the function.

1 Like