Word Blanks confusion!

Word Blanks confusion!
0

#1

Instructions:
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.

My code below:

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

  // Your code above this line
  return result="My" + "myName" + "her" + "myAdjective" + "and" + "myVerb" + "myAdverb" +"go";
}

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

Please, someone should help me with further explanation on what the code instructions is demanding for cause am confused and don’t understand it.


#2

So you have a series of parameters, myNoun, myAdjective, myVerb, and myAdverb. Don’t put those in quotes, or they’re used as a string, rather than as a variable. Also, be mindful of spaces – when you do "My"+myName, you’ll get Mydog – may not be what you actually WANT.


#3
  1. You don’t want to return a statement with an assignment you want to return a value. (You don’t want to do something like return result =...).
  2. When you put something like myAdjective in quotes, it is just the string “myAdjective” rather than the variable myAdjective.
  3. You need spaces between all words.

#4

Not a bot, and FAST fingers. Well said, @ArielLeslie.


#5

Still don’t understand pls


#6

What don’t you understand?


#7

your previous explanation pls


#8

The first point: on the line where you return result, you should avoid assigning the value on that same line. Perhaps add a line where you put together the result string, then simply return THAT.

The second point is the same I made – if you have variables (as you do, in the parameters your function has been passed, myNoun, myVerb, myAdjective, myAdverb), they are variables. They are not strings. Strings, you would use by “putting quotes around them”. Variables, however, do not get quotes.

The third point is also one I made. In the strings you insert between your variables, you will need spaces before and after the words, as the variables you’ve been passed don’t have spaces.


#9
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result ="";
  // Your code below this line
   result= "My +"myNoun+" "is" + myAdjective + "are" + myVerb + " "+ myAverb +"!";

  // Your code above this line
  return result;
}

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

for hours i have been trying so many code ways to pass this test but still yet its not working. Am so confused and tired. please can anyone assist with an easy way of understanding the code?


#10

versus:

result= "My "+myNoun+" is "+myAdjective+" are " +myVerb+" "+myAdverb +"!";
  1. Each piece of the string you’re building needs to be joined to the next with the +, so move the plus sign out of the first quoted string.
  2. After the myNoun+, you immediately open and close a string with " " – so then the is" you have next is all confused, because it thinks is is a variable name here.

Other than that, it looks okay.