freeCodeCamp icon indicating copy to clipboard operation
freeCodeCamp copied to clipboard

Concatenating Strings with the Plus Equals Operator doesn't work

Open manju4ever opened this issue 10 years ago • 5 comments

Challenge Concatenating Strings with the Plus Equals Operator has an issue. User Agent is: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.103 Safari/537.36. Please describe how to reproduce this issue, and include links to screenshots if possible.

My code:

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

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

manju4ever avatar Feb 11 '16 15:02 manju4ever

When the example code is removed, the test fails even if the solution is correct:

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

If you Reset and then enter the solution directly below // Only change code below this line, it will pass.

This makes me wonder why the example code isn't just in the description sidebar since it has no practical purpose in the editor.

jamigibbs avatar Feb 11 '16 15:02 jamigibbs

Okay my bad. Sorry for the trouble did not read the instructions properly.

manju4ever avatar Feb 11 '16 15:02 manju4ever

i am on the same challenge right now and it did exactly as jamigibbs wrote but before i came looking for help and yes it still does not pass the part for the mystr+= will but the upper one for the var myster does not pass is thier a bug in it this is how it looks

// 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."; bottom myster += passes but top no matter how i changed it will not pass and i dont understand what im doing wrong

frogshelp avatar Sep 22 '16 17:09 frogshelp

removed solution by mod

heytoufiq avatar Dec 31 '16 07:12 heytoufiq

JavaScript Operators

The assignment operator += can concatenate strings.

osa9j avatar Apr 18 '17 18:04 osa9j