Forem

Cover image for Resolvendo exercícios do JSchallenger - (Javascript Basics #3)
ananopaisdojavascript
ananopaisdojavascript

Posted on

5 2

Resolvendo exercícios do JSchallenger - (Javascript Basics #3)

O que deve ser feito?

  • Escrever uma função que obtenha um valor como argumento
  • Retornar o tipo do valor

Espera-se que utilizemos typeof nesta função.

Para lembrar

typeof é um operador que retorna uma string com o tipo do valor informado.

function myFunction(a) {
   return typeof a
}
Enter fullscreen mode Exit fullscreen mode

Resultados

myFunction(1) // 'number'
myFunction(false) // 'boolean'
myFunction({}) // 'object'
myFunction(null) // 'object'
myFunction('string') // 'string'
myFunction(['array']) // 'object'
Enter fullscreen mode Exit fullscreen mode

Para quem quiser resolver o desafio, o link está aqui:

Get type of value

Gostou? Até a próxima anotação! :)

Top comments (0)

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay