# Word Blanks Exercise

**URL:** <https://forum.freecodecamp.org/t/word-blanks-exercise/268311>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [March 30, 2019, 6:59pm UTC](https://forum.freecodecamp.org/t/word-blanks-exercise/268311 "2019-03-30T18:59:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![drenationlive](https://avatars.discourse-cdn.com/v4/letter/d/839c29/32.png) [@drenationlive](https://forum.freecodecamp.org/u/drenationlive)\
**Post date:** [March 30, 2019, 6:59pm UTC](https://forum.freecodecamp.org/t/word-blanks-exercise/268311/1 "2019-03-30T18:59:11Z")

</div>

**Tell us what’s happening:**

I don’t understand why this is right! I caved in and hit the “Get a hint” button to get the missing information. My original code was way off.

Not sure how I was able to pass the 3 required items below with this line of code. result+= “My “+myAdjective+” “+myNoun+” “+myVerb+” very “+myAdverb+”.”;

Passed

`wordBlanks("","","","")` should return a string.

Passed

`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).

Passed

`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 code so far**  
var

```js

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  // Your code below this line
  var result = "";
result+= "My "+myAdjective+" "+myNoun+" "+myVerb+" very "+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 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36`.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [March 30, 2019, 7:12pm UTC](https://forum.freecodecamp.org/t/word-blanks-exercise/268311/2 "2019-03-30T19:12:23Z")

</div>

If you add `console.log(result)` as last line before the “your code above this line”, you will see printed in the console the string

You will see that you have created a string with the arguments of the function (last line of the whole code) in the place of the variables. You can change those arguments and you will see the text in the console change

But right now you just need to understand how to concatenate strings contained in variables with other strings , the function part will be explained later

---

<div class="post-metadata">

**Author:** ![drenationlive](https://avatars.discourse-cdn.com/v4/letter/d/839c29/32.png) [@drenationlive](https://forum.freecodecamp.org/u/drenationlive)\
**Post date:** [March 30, 2019, 11:24pm UTC](https://forum.freecodecamp.org/t/word-blanks-exercise/268311/3 "2019-03-30T23:24:20Z")

</div>

Hi ieahleen,

I see that I get “My big dog ran very quickly.”

I even played around with the code. I was able to add to it.

I understand concatenation. What I don’t understand is how it knows where out pull the word list from based on the code. I’m going to keep playing with it till I get it.

```auto

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb, newword) {
  // Your code below this line
  var result = "";
result+= "My "+myAdjective+" "+myNoun+" "+myVerb+" very "+myAdverb+" "+newword+".";
  // Your code above this line
  return result;

  console.log(result)
}

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

```

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [March 31, 2019, 5:38am UTC](https://forum.freecodecamp.org/t/word-blanks-exercise/268311/4 "2019-03-31T05:38:07Z")

</div>

> [@drenationlive](#):
>
> wordBlanks(“dog”, “big”, “ran”, “quickly”, “outside”);

This is a function call (last line of the code), the values in the parenthesis are the values that are passed in the function

> [@drenationlive](#):
>
> function wordBlanks(myNoun, myAdjective, myVerb, myAdverb, newword) {…}

This is the function declaration, the variables in the parenthesis are the parameters - when a function is called the code is executed passing the arguments in the function parameters

Functions is a future subject, you will find it in a few lessons and understand what happens here better

> [@drenationlive](#):
>
> console.log(result)

This is the command to print things to the console, though you should put it before the return statement if you want it to be executed

> [@drenationlive](#):
>
> return result;

This is the return statement, and in this way you declare what value should be returned from the function

---

<div class="post-metadata">

**Author:** ![ArielLeslie](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/arielleslie/32/264841_2.png) [@ArielLeslie](https://forum.freecodecamp.org/u/ArielLeslie)\
**Post date:** [April 1, 2019, 2:52pm UTC](https://forum.freecodecamp.org/t/word-blanks-exercise/268311/5 "2019-04-01T14:52:57Z")

</div>

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make easier to read.

See [this post](http://forum.freecodecamp.com/t/forum-code-formatting/25574) to find the backtick on your keyboard. The “preformatted text” tool in the editor (`</>`) will also add backticks around text.

**Note:** Backticks are not single quotes.

![markdown_Forums](https://sea3.discourse-cdn.com/freecodecamp/uploads/default/original/3X/4/b/4b9a26f0c243380dd84935f4e29b92e3ecee8d05.gif)

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [February 2, 2021, 11:11am UTC](https://forum.freecodecamp.org/t/word-blanks-exercise/268311/6 "2021-02-02T11:11:26Z")

</div>

Closed on February 2, 2021, 11:11am UTC


