Appending variables to strings

Good morning everyone. Some one please help me here, what is wrong with my code

var anAdjective = “good!”;
var ourStr = "Learning to code is ";
ourStr += good;

You don’t have a variable named “good”, you have a variable named “anAdjective” :wink:

So how should it be? I am following the example given: This one,

// Example
var anAdjective = “awesome!”;
var ourStr = "Free Code Camp is ";
ourStr += anAdjective;

1 Like

Instead of good use the variable name, anAdjective, as the system is trying to figure out where good is defined. Another way is use “good!” instead of good(I think that’s what you were trying to achieve).

JsBin(not affiliated in any way) is a pretty awesome resource to debug short programs.

It should be this:

var anAdjective = "good!";
var ourStr = "Learning to code is ";
ourStr += anAdjective;

The content of variable is different, but the variable name stayed the same.

1 Like

Please look at this and tell me where I am going wrong:

// Example
var anAdjective = “awesome!”;
var ourStr = "Free Code Camp is ";
ourStr += anAdjective;

// Only change code below this line

var someAdjective = “good!”;
var ourStr = "Learning to code is ";
ourStr += someAdjective;

The computers reply is X Append someAdjective to myStr using the += operator

This has worked…
var anAdjective = “awesome!”;
var ourStr = "Free Code Camp is ";
ourStr += anAdjective;

// Only change code below this line

var someAdjective = “good!”;
var myStr = "Learning to code is ";
myStr += someAdjective;

1 Like