# Basic JavaScript - Word Blanks

**URL:** <https://forum.freecodecamp.org/t/basic-javascript-word-blanks/550523>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [September 3, 2022, 4:18pm UTC](https://forum.freecodecamp.org/t/basic-javascript-word-blanks/550523 "2022-09-03T16:18:58Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![yvonne.watsonrpn](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/yvonne.watsonrpn/32/266758_2.png) [@yvonne.watsonrpn](https://forum.freecodecamp.org/u/yvonne.watsonrpn)\
**Post date:** [September 3, 2022, 4:18pm UTC](https://forum.freecodecamp.org/t/basic-javascript-word-blanks/550523/1 "2022-09-03T16:18:58Z")

</div>

**Tell us what’s happening:**  
Hi all. I have tried everything on the site, and still says its wrong. Any suggestions please!

**Your code so far**

```js
const myNoun = "dog";
const myAdjective = "big";
const myVerb = "ran";
const myAdverb = "quickly";
// Only change code below this line
const wordBlanks = "My" + myNoun + "saw a" + myAdjective + "cat" + "and" + myVerb +"very"+ myAdverb + "I heard a loud noise" + "and then" + "slowly" + "walked away."; // Change this line
// Only change code above this line

```

**Your browser information:**

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36`

**Challenge:** Basic JavaScript - Word Blanks

**Link to the challenge:**

> **[freeCodeCamp.org](https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/word-blanks)**
>
> Learn to Code — For Free

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [September 3, 2022, 4:19pm UTC](https://forum.freecodecamp.org/t/basic-javascript-word-blanks/550523/2 "2022-09-03T16:19:55Z")

</div>

Try console.loging the string. What does it look like?

---

<div class="post-metadata">

**Author:** ![yvonne.watsonrpn](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/yvonne.watsonrpn/32/266758_2.png) [@yvonne.watsonrpn](https://forum.freecodecamp.org/u/yvonne.watsonrpn)\
**Post date:** [September 3, 2022, 4:22pm UTC](https://forum.freecodecamp.org/t/basic-javascript-word-blanks/550523/3 "2022-09-03T16:22:00Z")

</div>

// running tests  
wordBlanks should contain all of the words assigned to the variables myNoun myVerb myAdjective and myAdverb separated by non-word characters (and any additional words of your choice). // tests completed

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [September 3, 2022, 4:23pm UTC](https://forum.freecodecamp.org/t/basic-javascript-word-blanks/550523/4 "2022-09-03T16:23:03Z")

</div>

Yes. And what does your string look like?

---

<div class="post-metadata">

**Author:** ![yvonne.watsonrpn](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/yvonne.watsonrpn/32/266758_2.png) [@yvonne.watsonrpn](https://forum.freecodecamp.org/u/yvonne.watsonrpn)\
**Post date:** [September 3, 2022, 4:30pm UTC](https://forum.freecodecamp.org/t/basic-javascript-word-blanks/550523/5 "2022-09-03T16:30:50Z")

</div>

const wordBlanks = “My” + myNoun + “saw a” + myAdjective + “cat” + “and” + myVerb +“very”+ myAdverb + “I heard a loud noise” + “and then” + “slowly” + “walked away.”;

---

<div class="post-metadata">

**Author:** ![hbar1st](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/hbar1st/32/372649_2.png) [@hbar1st](https://forum.freecodecamp.org/u/hbar1st)\
**Post date:** [September 3, 2022, 4:32pm UTC](https://forum.freecodecamp.org/t/basic-javascript-word-blanks/550523/6 "2022-09-03T16:32:19Z")

</div>

> [@yvonne.watsonrpn](#):
>
> `const wordBlanks = "My" + myNoun + "saw a" + myAdjective + "cat" + "and" + myVerb +"very"+ myAdverb + "I heard a loud noise" + "and then" + "slowly" + "walked away."; // Change this line`

Using the + operator basically _smushes_ the values on the right and left into a single string.  
So if you write:

“I” + “like” + “coding”

you will get

Ilikecoding

Notice, there are no spaces. So pay attention to this. You will need spaces…

---

<div class="post-metadata">

**Author:** ![yvonne.watsonrpn](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/yvonne.watsonrpn/32/266758_2.png) [@yvonne.watsonrpn](https://forum.freecodecamp.org/u/yvonne.watsonrpn)\
**Post date:** [September 3, 2022, 4:41pm UTC](https://forum.freecodecamp.org/t/basic-javascript-word-blanks/550523/7 "2022-09-03T16:41:45Z")

</div>

This is what I tried:  
const wordBlanks = “My”+ myNoun +“saw a”+ myAdjective +“cat and”+ myVerb +“very”+ myAdverb +“I heard a loud noise then slowly walked away.”;

and this:  
const wordBlanks = “My”+myNoun+“saw a”+myAdjective+“cat and”+myVerb+“very”+myAdverb+“I heard a loud noise then slowly walked away.”;

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [September 3, 2022, 4:42pm UTC](https://forum.freecodecamp.org/t/basic-javascript-word-blanks/550523/8 "2022-09-03T16:42:04Z")

</div>

> [@JeremyLT](#):
>
> Try console.loging the string. What does it look like?

I’m asking about the final result, not your code. What does the string you created look like?

Console.log() the string and look at it.

```javascript
console.log(wordBlanks);

```

---

<div class="post-metadata">

**Author:** ![hbar1st](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/hbar1st/32/372649_2.png) [@hbar1st](https://forum.freecodecamp.org/u/hbar1st)\
**Post date:** [September 3, 2022, 4:44pm UTC](https://forum.freecodecamp.org/t/basic-javascript-word-blanks/550523/9 "2022-09-03T16:44:54Z")

</div>

if you scroll down in the bottom-right corner of your screen (also called a console area), you will see a print-out of whatever you logged using the console.log command.  
(it is sometimes hidden as the result of the test comes first, so just scroll down to see it)

---

<div class="post-metadata">

**Author:** ![yvonne.watsonrpn](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/yvonne.watsonrpn/32/266758_2.png) [@yvonne.watsonrpn](https://forum.freecodecamp.org/u/yvonne.watsonrpn)\
**Post date:** [September 3, 2022, 4:45pm UTC](https://forum.freecodecamp.org/t/basic-javascript-word-blanks/550523/10 "2022-09-03T16:45:14Z")

</div>

SyntaxError: unknown: Invalid left-hand side in assignment expression. (6:0)

4 | const myAdverb = “quickly”;  
5 | // Only change code below this line

> 6 | Console.log(wordBlanks) = “My”+myNoun+“saw a”+myAdjective+“cat and”+myVerb+“very”+myAdverb+“I heard a loud noise then slowly walked away.”; // Change this line  
> | ^  
> 7 | // Only change code above this line

---

<div class="post-metadata">

**Author:** ![yvonne.watsonrpn](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/yvonne.watsonrpn/32/266758_2.png) [@yvonne.watsonrpn](https://forum.freecodecamp.org/u/yvonne.watsonrpn)\
**Post date:** [September 3, 2022, 4:46pm UTC](https://forum.freecodecamp.org/t/basic-javascript-word-blanks/550523/11 "2022-09-03T16:46:21Z")

</div>

SyntaxError: unknown: Invalid left-hand side in assignment expression. (6:0)

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [September 3, 2022, 4:47pm UTC](https://forum.freecodecamp.org/t/basic-javascript-word-blanks/550523/12 "2022-09-03T16:47:36Z")

</div>

That’s wrong syntax. Don’t do that

Put the console.log statement on a separate line after you create your string.

And look at the result. There aren’t any spaces between the words. You need to include spaces.

---

<div class="post-metadata">

**Author:** ![yvonne.watsonrpn](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/yvonne.watsonrpn/32/266758_2.png) [@yvonne.watsonrpn](https://forum.freecodecamp.org/u/yvonne.watsonrpn)\
**Post date:** [September 3, 2022, 4:58pm UTC](https://forum.freecodecamp.org/t/basic-javascript-word-blanks/550523/13 "2022-09-03T16:58:26Z")

</div>

SyntaxError: unknown: Missing semicolon. (6:38)

4 | const myAdverb = “quickly”;  
5 | // Only change code below this line

> 6 | const wordBlanks = “My”+ myNoun +“saw” “a”+ myAdjective +“cat” “and”+ myVerb +“very”+ myAdverb +“I heard a loud noise then slowly walked away.”;  
> | ^  
> 7 | console.log(wordBlanks); // Change this line  
> 8 | // Only change code above this line

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [September 3, 2022, 5:00pm UTC](https://forum.freecodecamp.org/t/basic-javascript-word-blanks/550523/14 "2022-09-03T17:00:16Z")

</div>

Yes, the code will error if you do that.

Why did you delete some of the + between the strings?

---

<div class="post-metadata">

**Author:** ![yvonne.watsonrpn](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/yvonne.watsonrpn/32/266758_2.png) [@yvonne.watsonrpn](https://forum.freecodecamp.org/u/yvonne.watsonrpn)\
**Post date:** [September 3, 2022, 5:06pm UTC](https://forum.freecodecamp.org/t/basic-javascript-word-blanks/550523/15 "2022-09-03T17:06:07Z")

</div>

const wordBlanks = “My” + myNoun + “saw” + “a” + myAdjective + “cat” + “and” + myVerb + “very” + myAdverb + “I heard a loud noise then slowly walked away.”;

console.log(wordBlanks); // Change this line  
This is what I got;  
// running tests

```auto
wordBlanks

```

should contain all of the words assigned to the variables

```auto
myNoun

```

,

```auto
myVerb

```

,

```auto
myAdjective

```

and

```auto
myAdverb

```

separated by non-word characters (and any additional words of your choice). // tests completed // console output MydogsawabigcatandranveryquicklyI heard a loud noise then slowly walked away. MydogsawabigcatandranveryquicklyI heard a loud noise then slowly walked away.

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [September 3, 2022, 5:13pm UTC](https://forum.freecodecamp.org/t/basic-javascript-word-blanks/550523/16 "2022-09-03T17:13:06Z")

</div>

> [@yvonne.watsonrpn](#):
>
> MydogsawabigcatandranveryquicklyI heard a loud noise then slowly walked away.

And do you see any spaces between the words in the first part of the sentence here?

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [March 5, 2023, 5:13am UTC](https://forum.freecodecamp.org/t/basic-javascript-word-blanks/550523/17 "2023-03-05T05:13:16Z")

</div>

Closed on March 5, 2023, 5:13am UTC

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
