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

204
Visualizações
Need clarification as to why code is correct
const isString = (a, b, c) => {
  if (((typeof a) == "string") && ((typeof b) == "string") && ((typeof c) == "string")) {
    return "strings";
  }
  return "not strings";
}

Why is the => after the argument required in order for this to work? I got this test question correct via trial and error, but I don't understand why it doesn't work without =>.

Here are the instructions.

Create a function called "isString" that takes 3 arguments (x1, x2, x3)

  • Check if each argument is a string using typeof.
  • If each argument is a string, return "strings".
  • If each argument is NOT a string, return "not strings".
about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

The => is the syntax for an arrow function

about 4 years ago · Juan Pablo Isaza Relatório

0

The => operator is required because that is how javascript's syntax for anonymous functions works. This is creating a function equivilent to isString(a,b,c) {...}. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions

about 4 years ago · Juan Pablo Isaza Relatório

0

Assuming that this is javascript, the => is indicating that it is part of an Arrow Function. The following two codes are equivalent as for the understanding of the two.

// function declaration
function isString (a, b, c) {
  if (((typeof a) == "string") && ((typeof b) == "string") && ((typeof c) == "string")) {
    return "strings";
  }
  return "not strings";
}
// arrow function declaration; can also use `var` instead of `const`
const isString = (a, b, c) => {
  if (((typeof a) == "string") && ((typeof b) == "string") && ((typeof c) == "string")) {
    return "strings";
  }
  return "not strings";
};
about 4 years ago · Juan Pablo Isaza Relatório
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