Basic JavaScript course: Word Blanks, mad libs style fill in the blanks

Tell us what’s happening:

‘What am I missing here?’

'The assignment is as follows: ## Basic JavaScript: Word Blanks
We will now use our knowledge of strings to build a “Mad Libs” style word game we’re calling “Word Blanks”. You will create an (optionally humorous) “Fill in the Blanks” style sentence.

In a “Mad Libs” game, you are provided sentences with some missing words, like nouns, verbs, adjectives and adverbs. You then fill in the missing pieces with words of your choice in a way that the completed sentence makes sense.

Consider this sentence - "It was really ____ , and we ____ ourselves ____ ". This sentence has three missing pieces- an adjective, a verb and an adverb, and we can add words of our choice to complete it. We can then assign the completed sentence to a variable as follows:

var sentence = “It was really” + “hot” + “, and we” + “laughed” + “ourselves” + “silly.”;

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, a, b, c, d) {
     var result = "";
  // Your code below this line
  myNoun = "dog";
  myAdjective = "big";
  myVerb = "ran";
 myAdverb = "quickly";
 a = "cat";
 b = "little";
 c = "hit";
 d = "slowly";
 
result += "Her " + myAdjective + myNoun + myVerb + " very " + myAdverb + " . " + "But " + " my " + b + a + c + " very " + d + " . ";
  // Your code above this line
  return result;
}

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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0 Safari/605.1.15.

Link to the challenge:

  1. You should not add any new parameters (remove a,b,c,d).

  2. You should not reassign the parameter values (remove all assignments inside the function, except result to hold the final string).

  3. All words should be separated by spaces.

"Her " + myAdjective + myNoun
// Her bigdog

vs

"Her " + myAdjective + " " + myNoun
// Her big dog

See if this post helps.

Thank you for your quick answer.
I have now removed the added parameters, although I have seen a string of posts with solutions containing added parameters for personification. I have also separated by spaces, but I am not quite sure the reassignment point. Which assignments inside the function shall I remove, and how I am to use the result string correctly?