I found the solution but i m a bit confused

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = “”;
// Your code below this line
result += "i have a “+myAdjective+”, very very big, “+myNoun+”. " + “But he “+myVerb+” off somewhere very “+myAdverb+”.”;

// Your code above this line
return result;
}

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

This is the correct answer of that challenge, but the only thing that i was doing wrong when i first did it was, i was missing those ‘+’ before and after the vars (if not pls tell me what they really are). So my question is, if var dogName = “bob”; and if i type “My dog’s name is dogName.” won’t the output will be “My dog’s name is bob”? so what is that “+” actually doing?
And Its confusing me.

In your example, in order to show dogName as bob you must write: "My dog’s name is " + dogName + "."
Otherwise the output will just be [My dog’s name is dogName.]

The text inside the quotes are strings, strings will be printed the way they are written. The + operator allows you to concatenate strings and variables together.

1 Like