Why uppercase don't work in this challenge

Hi, i want to know why the uppercase don’t work in this challenge

Challenge: https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/es6/use-arrow-functions-to-write-concise-anonymous-functions

The code of the challenge, mine and correct:

//Code of the challenge
var magic = function() {
  return new Date();
};

//My answer (don't work)
const MAGIC = () => new Date();


// Correct answer
const magic = () => new Date();

Someone know why the uppercase “MAGIC” don’t work? I thought it is good practice to write const variables in uppercase.

javascript is case sensitive, if the tests ask for magic you need to use that

also, even if you use const, an array, object or function are still not really constant
just think of:

const obj = {};
obj.myKey = "value";
console.log(obj); // {obj: "value"}

the convention is usually just used for immutable data types (booleans, null, undefined, numbers and strings), which really can’t be modified

1 Like