Word Blanks Unable to figure out what im missing

Word Blanks Unable to figure out what im missing
0.0 0

#1

Tell us what’s happening:
Im not %100 sure what i am doing wrong. It’s telling me "assignment to undeclared variable cat, which i thought i assigned to "cat

Your code so far


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

result = "my" + "myAdjective" + "myNoun" + "myVerb" + "very" + "myAdverb" + "and my" + "little" + "cat" + "was in the way and" + "got" + "slowly" + "hit";
  // 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 (Windows NT 6.1; Win64; x64; rv:60.0) Gecko/20100101 Firefox/60.0.

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


#2

OK, you’re doing much too much work here. You are being passed the noun, adjective, adverb, and verb. You don’t need to define them, you don’t need anything. You just need to concatenate a string together that uses each one once. For example, if I had a mini version:

function miniWordBlanks(myNoun, myVerb) {
  return "He " + myVerb + " " + myNoun + " while wearing a hat."
}

It’s that simple. It could even be simpler, but I don’t want to scare you.) Don’t forget spaces between words.

Some reasons why your failed, you were initializing variables before they were declared, for example cat="cat"; - which is not needed anyway.

And in your string, you referred to your variable names with quotes around them so JS didn’t know they were variables.

And of course it would have also failed because of spaces.

I think a lot of people run into a conceptual block on this challenge because they have no idea what mad libs are.