-3
const datee = () => document.write(new Date());

datee; //no response, same for console.log

const datei = () => new Date();

console.log(datei); // () => new Date();

The comments above shows what they are printing if they are printing anything

Phil
  • 157,677
  • 23
  • 242
  • 245
  • 2
    You forgot to call any of the functions – CertainPerformance Feb 02 '22 at 04:12
  • In the dev-tools console on this page, `const datee = () => document.write(new Date()); console.log(datee)` for me shows _"() => document.write(new Date())"_ – Phil Feb 02 '22 at 04:14
  • how do i fix it? how do i get the date?? – Sivan Kakkar Feb 02 '22 at 04:16
  • you need to execute the function `var a = () => console.log(new Date()); a();` – Posto Feb 02 '22 at 04:17
  • It's not clear what the problem is here. Are you asking about the _"no response, same for console.log"_ where you would expect to see the function definition logged or are you asking about why your script isn't executing `document.write(new Date())`? – Phil Feb 02 '22 at 04:19

1 Answers1

0

You have to call the arrow functions just like a regular inline function

const datei = () => new Date();
console.log(datei()); // returns Date Object;

// Hovwever, without calling (without "()")
const datei = () => new Date();
console.log(datei); // () => new Date();
KyleRifqi
  • 489
  • 2
  • 15