Basic JavaScript - Word Blanks

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

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:

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

// 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

Yes. And what does your string look like?

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

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…

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.”;

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.

console.log(wordBlanks);

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)

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

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

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.

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

Yes, the code will error if you do that.

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

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

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 // console output MydogsawabigcatandranveryquicklyI heard a loud noise then slowly walked away. 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?

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