Concatenating Strings with the Plus Equals Operator question

Tell us what’s happening:
What am I doing wrong?

Build myStr over several lines by concatenating these two strings: "This is the first sentence. " and "This is the second sentence." using the += operator. Use the += operator similar to how it is shown in the editor. Start by assigning the first string to myStr , then add on the second string.

Your code so far
var myStr = “This is the first sentence”;

myStr += “This is the second sentence.”


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

// Only change code below this line


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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.2988.0 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 missing a space and a dot at the end in the first string (also a semicolon but i don’t think the tests cares about that).

Thank you very much!

Hello @jdiggity

I am having the same problem

here is my code var myStr = 'This is the first sentence.'; myStr += 'This is the second sentence.';

Where did i go wrong here

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

or maybe that one

Your string is missing a space

I have added spaces still not accepting

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

Why the space at the end of the second string? That is counted as an error, as the tests match the string exactly

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

Still not accepting. note i have spaces after = sign and += signs as well

Thanks for helping out though :grinning:

1 Like

The spaces outsides the quotes don’t matter, it’s inside the quotes you are missing a space
You just returned to the above situation, you just need to add a single space so that there is a space, as is grammatically correct, between the full stop and the following letter

1 Like
// Only change code below this line
var myStr = "This is the first sentence. ";
myStr += "This is the second sentence.";

The first sentence. Whooooo this has been quite educational i might say, finally accepted

1 Like

var my = “HI HEllo”;
my += " HI BYE BYE";

Run this in your console.
Only you need space. before your Double inverted comma.

Or else try this thing
var my = ‘HI HEllo’ + ’ HI BYE BYE’;

@caseyanmol hi dude
my code was accepted

how is yours get accepted? i still have same problem as you before

If you copy your code here we may be able to help you…

var myStr = "This is the first sentence.(// u need to give a space here) ";
myStr += “This is the second sentence.”;