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

391
Vistas
Functions and Strings in JavaScript

I'm just starting programming, I have this issue and I can't finish it. where to use startsWith inside the function?

function werewolfCheck(name) {
  if (name === str.startsWith('were')) {
    return 'It is a werewolf';
  } else {
    return 'Just a regular person';
  }
}

var werewolfCheck = name.str.startsWith('were');
werewolfCheck('werebrian');

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

function werewolfCheck (name) {
  if (name.slice(0,4) === "were"){
    return "it is a werewolf"
  } else {
    return "just a regular person"
  }
};
console.log(werewolfCheck("werebrian"))

about 4 years ago · Juan Pablo Isaza Denunciar

0

  1. in the function str doesn't exist so you just need to check to see if name (the argument you passed in) starts with 'were'.

  2. var werewolfCheck... does nothing useful so you can remove it.

  3. The return from the function is a string so you need some way to display that string. I've logged it to the console in this example.

function werewolfCheck(name) {
  if (name.startsWith('were')) {
    return 'It is a werewolf';
  } else {
    return 'Just a regular person';
  }
}

console.log(werewolfCheck('werebrian'));
console.log(werewolfCheck('Billy Joel'));

about 4 years ago · Juan Pablo Isaza Denunciar

0

  function werewolfCheck(name){
    if(name.startsWith("were"))
      return "It is werewolf";
    return "Just a regular person";
  }

  werewolfCheck("werebrain");
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