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

393
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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