How do i make myStr contain both first and second sentence?

Tell us what’s happening:

Your code so far


// Example
var ourStr = "I come first. ";
ourStr += "I come second.";

// Only change code below this line

var myStr = "This is the ";
myStr += "first sentence. ";
myStr += "second sentence. ";

Your browser information:

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

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/concatenating-strings-with-the-plus-equals-operator/

You are only adding the text “second sentence.” to myStr after the first update. To see a clearer picture, below your code, use console.log(myStr) and you should be able to see what the issue is.

1 Like

ok, so now i put this:

var myStr = "This is the ";
myStr += "first sentence. This is the second sentence. ";

and when i input console.log(myStr) it shows up as this:
This is the first sentence. This is the second sentence.

So it should be right?

You are returning the string. But read the instructions carefully. You need to do it twice.
var myVar = "Here is my text.";
myVar += " And here is some more text.";
console.log(myVar); // returns the above concat. What does myVar now equal?
What do you need to add to myVar at this point to create the string needed?

1 Like

i figured it out thanks!

please how did you do it. I am currently facing the same issue right now

If you have a question about a specific challenge as it relates to your written code for that challenge, just click the Ask for Help button located on the challenge. It will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.