Freecodecamp: Does not pass the: myStr should have a value of This is the first sentence. This is the second sentence.

Created on 11 Mar 2016  Â·  7Comments  Â·  Source: freeCodeCamp/freeCodeCamp

Challenge Concatenating Strings with the Plus Equals Operator has an issue.
User Agent is: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:44.0) Gecko/20100101 Firefox/44.0.
Please describe how to reproduce this issue, and include links to screenshots if possible.

My code:

// 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';



All 7 comments

Seems like you're missing a period at the end of the second sentence. :)

thanks

On Thu, Mar 10, 2016 at 5:35 PM, drk7891 [email protected] wrote:

Seems like you're missing a period at the end of the second sentence. :)

—
Reply to this email directly or view it on GitHub
https://github.com/FreeCodeCamp/FreeCodeCamp/issues/7492#issuecomment-195097556
.

Closing this as it seems to be solved.

Thanks for this solution.

Same problem:

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

Still giving me referenceError.

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

// Only change code below this line

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

Got it - -

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

OR

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

// Note the space after myStr = "This is the first sentence.
// there is a space before the ";
//That space is needed for the second line after the += to have a space before the first word of second sentence. Note the example below. This is how I was able to figure it out:

Concatenating Strings with the Plus Equals Operator
The ’+=’ operator can concatenate (link) strings easily. Make sure your spelling is right, and you’ve left appropriate spaces.

var str = "Hello ";
str += "coding"; // Now the string reads "Hello coding"
str += "camper!"; // And now the string reads "Hello codingcamper!

reference link: https://guide.freecodecamp.org/certifications/javascript-algorithms-and-data-structures/basic-javascript/concatenating-strings-with-the-plus-equals-operator/

Hope this helps someone else!

Was this page helpful?
0 / 5 - 0 ratings