Appending with += not getting it

Tell us what’s happening: i dont understand i have checked and checked it says that the + append on line 5 is the problem

3 | var someAdjective = “worthwhile”;
4 | var myStr = "Learning to code is ";

5 | var myStr += someAdjective;
help please

Your code so far


// Change code below this line

var someAdjective = "worthwhile";
var myStr = "Learning to code is ";
var myStr += someAdjective;

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36.

Challenge: Appending Variables to Strings

Link to the challenge:

You are close… remember, you only need to declare myStr once!

so, brother, you are doing a mistake in line 5 .
you have to append someAdjective to myStr but you are doing two mistakes

  1. you are declaring a new variable to store it which could be done but no need to do here .
    and
  2. you are declaring a variable with the same name using var which is an error in javascript you can do it with other key word like let also not needed here.

what to do then

var someAdjective = "worthwhile";

var myStr = "Learning to code is ";

myStr += someAdjective;





console.log(myStr)//output: Learning to code is worthwhile


this is going to append the someAdjective with the myStr and also going to store it in the existing myStr variable .

hope this will help . :slightly_smiling_face:

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

You can post solutions that invite discussion (like asking how the solution works, or asking about certain parts of the solution). But please don’t just post your solution for the sake of sharing it.
If you post a full passing solution to a challenge and have questions about it, please surround it with [spoiler] and [/spoiler] tags on the line above and below your solution code.

thank you i did it without this advice. i tried it again with another phrase and it seemed to work. thank you to every one it is greatly appreciated. i think this community is excellent thanks again !

thank you i did it without this advice. i tried it again with another phrase and it seemed to work. thank you to every one it is greatly appreciated. i think this community is excellent thanks again !
[/quote]

1 Like