0

Hi i have to create a function that recognizes names- Polish names. Its quiet easy, bc 99% of female names ends with "a", where mens not, the only man name who ends with "a" is a “Bonawentura”. So to i tried create function that tooks in record that the names with "a" are female exception to “Bonawentura”. So the function will work that if its a female name = false, if man = true f.e input:

“Ala”, “Jacek”, “Bonawentura”

and output:

false, true, true

that what i tried:

function isMaleName() {
    if ( str.endsWith("a") = false)
}

Cheers, and appriciate any help/tips. Have a nice day.

Panasiux2
  • 33
  • 1
  • 5
  • Instead of `=`, which is the assignment operator, you should be using an equality operator, either `==` ([link](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Equality)) or `===` ([link](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Strict_equality)). Or you can directly check it via `!str.endsWith("a")`. – Steve Feb 27 '21 at 09:43

1 Answers1

1

You coulf check for endig or exceptional name.

function isMaleName(string) {
    return !string.endsWith("a") || string === 'Bonawentura';
}

console.log(['Ala', 'Jacek', 'Bonawentura'].map(isMaleName));
Nina Scholz
  • 376,160
  • 25
  • 347
  • 392