Appending variables to strings

Appending variables to strings
0.0 0

#1

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;


#2

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


#3

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;


#4

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.


#5

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.


#6

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


#7

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;