Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

392
Views
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 answers
Answer question

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 Report

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!