How can it be separated by non-word characters (and any additional words in your madlib), i didn't get it

Tell us what’s happening:

Your code so far


var myNoun = "dog";
var myAdjective = "big";
var myVerb = "ran";
var myAdverb = "quickly";


// Only change code below this line
var wordBlanks = "my" + myNoun + ", saw a " + myAdjective + " and he" +  myVerb + "faster and very" + myAdverb +" "; 
// 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/89.0.4389.90 Safari/537.36.

Challenge: Word Blanks

Link to the challenge:

1 Like

Hi @ugyentenzin,

Let’s look at what your function is storing now as wordBlanks:

'mydog, saw a big and heranfaster and veryquickly '   

Look for example at the beginning of the string “mydog”.
If you see how the string is created: "my" + myNoun you will see that there is no spaces between the two words.

If you want to add a space you need to be specific about it:

// adding a space in the string
"my " + myNoun

// or concatenating a space
"my" + " " + myNoun

You can go a bit extra and have the space stored as a variable and then reusing it when making your string

var space = " ";
var name = "Bob";
var title = "The Builder";

var string = name + space + title;
// 'Bob The Builder'

Hope this helps :sparkles:

Thank you! It helped me.

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