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

199
Vistas
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 Respuestas
Responde la pregunta

0

The => is the syntax for an arrow function

about 4 years ago · Juan Pablo Isaza Denunciar

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 Denunciar

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 Denunciar
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