Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

115
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda