I tried doing this but it didn’t work:
const magic = () => Date();
The answer for this challenge is
const magic = () => new Date();
What does the ‘new’ keyword do and why is it necessary?
Thank you for the help!
I tried doing this but it didn’t work:
const magic = () => Date();
The answer for this challenge is
const magic = () => new Date();
What does the ‘new’ keyword do and why is it necessary?
Thank you for the help!
new
is just creating the instance of the Date
object, which is returned later by the function. This part isn’t specific for the “arrow functions”, but that’s how instances of objects are created in javascript.
Thank you for the help!!