/learn - section ES6 - use arrow functions - ISSUE

/learn - section ES6 - use arrow functions - ISSUE
0

hi Folks,
I tried to solve this challenge (/learn - ES6, lesson 6) by using this arrow function;
const MAGIC = () => new Date();
its rejected on checks 2-4 inclusive, which it shouldnt be?
When i change the code to;
const magic = () => new Date();
all the tests pass.
Im a newbie so these errors had me scratching my head A LOT! Surely if the variable is to be defined using const, magic should be in all caps? If im dead wrong, ill apologize…


Same goes for lesson 7
when i name the arrow function const variable as ALL_CAPS as per expected convention, the tests wont pass…
:face_with_monocle:

the variable name in all caps is a convention for numbers or strings, which are actually contants, considering that functions, arrays, objects can still change even if defined with const, it is not much used for these

probably in the lesson text there is written how to name the function, and you need to match that exactly

also, please, next time

If you have a question about a specific challenge as it relates to your written code for that challenge, just click the Ask for Help button located on the challenge. It will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.

1 Like

It’s a bit misleading the earlier lesson where it says that. There is a convention in many languages that constant values (values that do not ever change within the program) are capitalised. They are special, and that’s why they are capitalised, as a visual reminder. So for example, values for maths constants like π or physical constants like gravity. JS has a few set ones – as another example, if you look at the “static properties” section here, all.of those are capitalised constants:

But otherwise, in JS const variables aren’t special, they’re just written like any other variables. Don’t capitalise unless it’s a static constant value – IRL it’ll work fine, it’s just confusing, and in this case it’ll fail the tests because they are testing that what you’ve written matches the description

1 Like