Cant wrap my head around Word Blanks

Cant wrap my head around Word Blanks
0

#1

Dont know what needs to be done

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = “The” + myAdjective + " big" + myNoun + " dog" + myVerb + " ran" + myAdverb + " quickly" + " into a wall.";
return result;
}
wordBlanks(“dog”, “big”, “ran”, “quickly”);

This is the error
wordBlanks(“dog”, “big”, “ran”, “quickly”) should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).
wordBlanks(“cat”, “little”, “hit”, “slowly”) should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0.


#2

You should create a string which includes the arguments received by the function. It is important that there are spaces between all words. You should return the string that is created.


#3

Create a string where exactly?

You say i should return the string that is created where in my code is that done? and how?


#4

See that you are using parameters to capture whatever values that are passed in.

Instead of using hard-coded words in the result variable like you are doing now,

you can pass in these variables like myNoun and myAdjective to form a string of words. For ex.

var result = "Hello" + myNoun + "Nice to meet you"


#5

From what i understood you said, i did but both errors showing now, i have no idea

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = “The” + myAdjective + " big" + myNoun + " dog" + myVerb + " ran" + myAdverb + " quickly" + " into a wall.";
return result;
}
wordBlanks(“dog”, “big”, “ran”, “quickly”);

This is the error
wordBlanks(“dog”, “big”, “ran”, “quickly”) should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).
wordBlanks(“cat”, “little”, “hit”, “slowly”) should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).


#6

"The" has no space after the “The”. The returned string at this part for your first call will return “Thebig”…

The string for your first call will return “Thebig bigdog dogran ranquickly quickly into a wall.”


#7

I had the space in the word after " big"
Thinking thats how its done because im pretty sure i seen it like that, i will try re do it now!


#8

Yes its not even letting me run the test now
var result = “The ” + myAdjective + "big " + myNoun + "dog " + myVerb + "ran " + myAdverb + "quickly " + “into a wall.”;


#9

@Ardie94 your code has several problems.

  1. You are not using the parameters of the function properly. The task does not want you to just write a string but to learn how to use parameters and use variables in a string. For example:
let fruit = "apple";
let sentence = "Michael really loves " + fruit + "s";
console.log(sentence); // "Michael really loves apples"
  1. Your string has no spacing between the concatenated variables and the internal words of the string.
  1. You are adding your parameters for the function call into the string inside the function. If you did not pass any values into wordBlanks() it would read fine.
wordBlanks(); // The big dog ran quickly into a wall."

Do not focus only on completing the assignment. Take some time to review your code and understand what and why you are doing. I will share my function and show you how it should work so you have an example to work towards.

wordBlanks("thief", "frantic", "sprinted", "fearfully"); // "The frantic thief sprinted fearfully into a wall".

#10

Thank you, im just gona read about functions and parameters before doing the task with your help.

I knew that what you are sying to me was needed but the way the task is worded i just couldnt figure it out without some help, but i should of googled the function before posting for help which i know now to do in the future, im just going up a level here with js its all very new. Thanks again