Word Blanks = "My dog"+ "that is big"+ "ran very"+ "quickly for cover"

Tell us what’s happening:
I keep getting an error, What I understand is that I’m suppose to create a sentence using the + operator to concatenate separate strings to form a new sentence inside a variable named wordBlanks and then assign it to the variable result.

Your code so far


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

  // Your code above this line
  return result;
}

// Change the words here to test your function

```wordBlanks("My dog"+ "that is big"+ "ran very"+ "quickly for cover");

**Your browser information:**

User Agent is: <code>Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36</code>.

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

I absolutely hated this; did it recently. At the time, I looked up on here if anyone else had had issues with it prior to me coming to a complete halt on it, and there were lots of forum posts about it.

I think I have written about it on here before, but it feels like the challenge comes at a really odd point in the lessons (especially given the previous challenges have been on bracket notation and concatenation comes way before that).

My advice would be to use the get a hint button for this lesson. It does a really good job of explaining what you need to do without actually giving away the answer - and once you’ve read it, you’ll have a lightbulb moment.

This, I’m sure, will seem really easy to experienced JS people, but it completely stumped me and that was after finding the previous lessons relatively straightforward.

I don’t understand this line of code in your solution.

var result =+ wordBlanks;

You simply have to make a sentence and concatenate the noun, adj, verb and adverb into your sentence , store it in "result "and return it.

You do, but there is also more to it than that which includes the extra additions to the wordBlanks function at the bottom of the page. Just think there’s so much to trip you up here - bearing in mind most people that do it are rank amateurs at coding in general, never mind JS.

There are a lot of requests for help on this example. After skimming through several posts and responses, I’m led to believe that the error lies entirely in the spacing. You can try to use the += or the + operator, but the + operator works well enough alone. Both of the following attempts clear the test… check it out:


function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
// Your code below this line
var result = "The " +myNoun+ " with " +myAdjective+ " ears " +myVerb+ " to the bed " +myAdverb+ “.”;

// Your code above this line
return result;
}

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


…this worked too:


function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
// Your code below this line
var result = “The “+myNoun+” with “+myAdjective+” ears “+myVerb+” to the bed “+myAdverb+”.”;

// Your code above this line
return result;
}

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


The first several attempts at this, I thought I was diligent with my spacing, but once it passed, I realized that the difference was in the spacing.

1 Like

I think this challenge needs to be fixed, the sentence given in the code example does not use correct spacing.

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

console.log(sentence)

It was reallyhot, and welaughedourselvessilly.

It also does not explain very well that “hot”, “laughed” and “silly” are the actual values of the variables (parameters) adjective, verb, and adverb.

For none native English speaking people I think it is likely a poor way of teaching string concatenation. I think the introduction of grammar is completely unnecessary and likely confusing.