js-mentorship-razvan / javascript

Javascript study notes
GNU General Public License v3.0
22 stars 2 forks source link

Regexp Basics - is it a vowel? #565

Closed RazvanBugoi closed 4 years ago

RazvanBugoi commented 4 years ago

https://www.codewars.com/kata/567bed99ee3451292c000025/train/javascript

RazvanBugoi commented 4 years ago
String.prototype.vowel = function() {
  let vowels = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'];
    return (/^[aeiouAEIOU]$/g).test(this);
};

String.prototype.vowel = function() {
  let vowels = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'];
    return this.length == 1 ? (/^[aeiouAEIOU]$/g).test(this) : false;
};