Struggling with Word Blanks Excercise

I don’t understand the exercise. ive seen the solution but don’t understand why it works…

Your code so far


function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  // Your code below this line
  var result = "";
result += " " + "myAdjective" + " "+ "myNoun" + " " + "myVerb" + " "+ "myAdverb";
  // 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_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36.

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

does not work because you are encasing your variables in quotation marks, effectively making JS think they are strings instead:

result += myAdjective + " " + myNoun + " " + myVerb + " " + myAdverb;

might work better. :slight_smile:

And as an additional note, this whole:

var result = "";
result += //your data here

is ridiculous unneeded complexity. Just assign your data directly to result:

var result = //concat that stuff here.

thank you so much!!!

1 Like