I can't understand how should I do this test!

Tell us what’s happening:

This lesson is a little bit complicated and I think they need to work on it.
I even can’t understand what is the question and the test.
Hope someone help me to learn it.

Your code so far


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

  // 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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36.

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

This result should be a sentence fomed using the arguments given in the function.
For example:
If i want to join two words and make a new word:

function joinWords(wordOne, wordTwo){
   var joinedWord = wordOne +  wordTwo; 
   return joinedWord;
}
joinWords("key","board") // returns "keyboard"

You’ll have to take care of spaces as well in your function.
Try to solve now.
See if that helps.

1 Like

Thanks a lot for the explanation I understand it clearly but still I have the problem to finish this exercise because I can’t understand what it wants.

It wants you to take four variables, and construct a string with them. You have to join them somehow, add strings in as you like, but demonstrate that you know how to construct a string using both string literals and variables.

your variables are myNoun, myVerb, etc.

String literals are things like spaces, "The", "over the snow"… whatever. Anything that is letters and numbers and spaces, symbols, whatever. Anything in a string is a string literal.

Combine those things, and create a sentence, and pass that back.

1 Like

In this case when you add two string it’s attached as a single word without space, and one of test said that you need to: ‘contain all of the passed in words separated by non-word characters (and any additional words in your madlib).’

Said that you need to add and and blank space between your parameters: + ' ' +

1 Like

Thank a lot for your help…

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb){
const result = "a " + myAdjective + " " + myNoun + " " + myVerb + " " + myAdverb;

return result;

}
wordBlanks(“dog”, “big”, “ran”, “quickly”);

Thank you so much, I just found what I should do…

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb){
const result = "a " + myAdjective + " " + myNoun + " " + myVerb + " " + myAdverb;

return result;

}
wordBlanks(“dog”, “big”, “ran”, “quickly”);

1 Like