Freecodecamp: Error in ES6: Declare a Read-Only Variable with the const Keyword

Created on 22 Jun 2018  路  32Comments  路  Source: freeCodeCamp/freeCodeCamp

Describe your problem and - if possible - how to reproduce it

I'm getting an error with the final test, despite having made the simple changes called for on the page:
console.log should be changed to print the SENTENCE variable.

Additionally I get a note of "invalid regular expression flag s" in the test box when run.

My code:
function printManyTimes(str) {
"use strict";

// change code below this line

const SENTENCE = str + " is cool!";
for(let i = 0; i < str.length; i+=2) {
console.log(SENTENCE);
}

// change code above this line

}
printManyTimes("freeCodeCamp");

Add a Link to the page with the problem

https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/declare-a-read-only-variable-with-the-const-keyword

Tell us about your browser and operating system

  • Browser Name: Firefox
  • Browser Version: 60.0.2 (64-bit)
  • Operating System: Windows 10 home

If possible, add a screenshot here

image

Most helpful comment

The problem is known and it is being fixed.

EDIT : So for these who are interested in, the reason is the following :
freeCodeCamp has a repo called curriculum. The PR fixing this bug has been merged in it. But they still have to upgrade their version of curriculum in other repos. Currently the version is 2.0.0 and they still have the 1.2.1 version in the learn repo.
So, the fix is getting here, you just have to wait a little more 馃檪

All 32 comments

It seems that the regex used to verify the console.log statement is incorrect. I got the fix 馃檪

Hi, using the code below I get the following test result, with the last test failing to pass:

// running test
Unexpected token ?
// tests completed

code:

function printManyTimes(str) {
  "use strict";

  // change code below this line

  const SENTENCE = str + " is cool!";
  for(let i = 0; i < str.length; i+=2) {
    console.log(SENTENCE);
  }

  // change code above this line

}
printManyTimes("freeCodeCamp");

Getting the exact same problem as @thekholm80 is getting.

Getting the same error
// running test Unexpected token ? // tests completed

Me too...when i check in esconsole.com it's okay.

Unexpected token ? error

function printManyTimes(str) {
"use strict";

// change code below this line

const SENTENCE = str + " is cool!";
for(let i = 0; i < str.length; i+=2) {
console.log(SENTENCE);
}

// change code above this line

}
printManyTimes("freeCodeCamp");

Please fix this error

I also got the exact same problem:Unexpected token ?

I know someone said they have the fix, but I am also getting the same error.

I tested right now this challenge. My message error is different:

// running test
invalid regular expression flag s
// tests completed

I just tested this:

function printManyTimes(str) {
  "use strict";
  // change code below this line
  const SENTENCE = str + " is cool!";
  for(let i = 0; i < str.length; i+=2) {
    console.log(SENTENCE);
  }
  // change code above this line
}
printManyTimes("freeCodeCamp");

And still get this response:

// running test
Unexpected token ?
// tests completed

same.. me too..

The problem is known and it is being fixed.

EDIT : So for these who are interested in, the reason is the following :
freeCodeCamp has a repo called curriculum. The PR fixing this bug has been merged in it. But they still have to upgrade their version of curriculum in other repos. Currently the version is 2.0.0 and they still have the 1.2.1 version in the learn repo.
So, the fix is getting here, you just have to wait a little more 馃檪

ow! I'm not the only one :)

I thought I was going crazy. Glad to know this is a bigger issue than just me.

I was really looking forward to getting another green check circle. :)

Just stumbled upon this problem. Weird.

Wow! a number of comments already here. Count me in as I am also facing the same problem. :smile:

Also having the exact same problem "Unexpected token ?"

is there any way to skip this "unexpected token ?" problem and continue to next one ?

@dilipsingh94 Go to the curriculum link on the top right and then click the lesson after this one in the ES6 unit to keep going. I don't think the certification can be completed till it's fixed, but you can keep working towards it while you wait.

I was able to complete everything except this challenge and was able to claim the certification.

I keep checking back because I'd still like to pass this challenge, though.

@Ems2theLee thanks

same problem here.

It's still occurring. Hasn't been fixed yet.

What error do you guys get ? This is working fine for me and has been fixed on my side.

@thomlom It's cleared for me now too. Might just need a hard refresh?

@thomlom thank it's working now

Hey - wow - yes it is indeed working now!?! I just passed that challenge! Coolio and finally!?! (FYI, though - I have two certs under my belt now, which means I have completed 10 projects, but my Welcome page says that I have only completed 5 out of 30 projects!?! I was able to 'claim' both certs, so there is definitely a disconnect somewhere!?!)

Seems to be working for everyone now, so I am going to close the issue. Thank you for taking care of it @thomlom!

Still not working for me.

@kalzimonium Is it giving you the regex error or the unexpected token one? Could you screenshot your results?

Didn鈥檛 work last night at the time I posted that comment. Checked it out this morning and it was fixed. Thank you, sir. I鈥檓 good now :)

Was this page helpful?
0 / 5 - 0 ratings