Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

119
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda