Concatenating Strings with the Plus Equals Sign

Hello guys, please can i get some help here.
I have written this code over and over again but it seems to be an error


d// 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; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 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

Your code is legit and it passes the test. Try to disable firefox plugins that could interfere or try it from a different browser.

d// Example
Remove the leading “d” there.
-J

Actually am using chrome browser. How do i disable the firefox plugin. but the code is working in my text editor.

Yet still it telling me to Use the += operator to build myStr

Sorry, I intended your browser not firefox. If you have plugins installed sometime these interfere with the correct execution of the test program. Try first to open and execute your code from a clean installation of an other browser like firefox.

I supposed it was a typo during copy paste, isn’t it?

it works

@archer_miles
Did you remove the example code or are you using this exact code block?

// 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.";

@MatteoCarotta
Yeah I imagine so but worth mentioning just in case I figured =).
-J

1 Like

I have removed that example, my code says
var myStr = "This is the first sentence. ";
myStr += “This is the second sentence.”;

But the test is telling me to still use the += operator

You have to leave the example. Copy the block above and try it.
-J

This code is the same as my mine but why is mine given me errors. Please can you check my test by clicking the link i provided in the first post.

It’s not the same. You removed the example code and you can’t do that.

Either copy the block above that I posted (your own code) or copy your code and reset the test and paste your code.
-J

It’s not much code. Restart the browser, reset the code with the dedicated button, and retype it without modifying the example.

Shouldn’t be that way IMO - I removed the example code from a lot of challenges and didn’t have this issue. I wonder if it’s a bug in the test suite that is verifying the example && the test.
-J

Thanks guys, it now working correctly. I really appreciate all your ideas to help me solve out this test.

1 Like

I think it is on certain questions. There have been multiple tests/questions I have completed where I was certain my code was correct but it kept failing so I checked the hints. Then I would see my solution was the same as the hinted one, so I would copy the function in the hints.

Result? Code failed still. Then I realised why: I changed the example call to the function to test it with different variables, or sometimes to just console.log the outputted return statement. :laughing:

1 Like

:laughing::laughing::laughing::laughing::laughing::sweat_smile: