Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

118
Views
different between two code : write a code in javascript which can return date?

I am newbie with javascript and trying to study this one and meet this problem. I must write a code which can return this year (for example 2021). I tried to write my code myself and here is my code

function getCurrentYear () {
var year = date.getFullYear();
return year
}

As you can see, I tried to define year by date.getFullYear();, then return year. But i failed.

Here is the answer

function getCurrentYear  () {
const date = new Date()
return date.getFullYear()
}

I do not understand why they define date as const ? and return like this ? Could you please give me the answer? Thank you very much for your time. Sorry for my English.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!