Javascript String vowel()

Description

Javascript String vowel()


/*/*from  www . j  a  va 2  s .c  o m*/
Implement String#vowel? (in Java StringUtils.isVowel(String)), which should return true if given object is a vowel, false otherwise.
*/

String.prototype.vowel = function() {
  return /^[aeiou]$/i.test(this);
};

Javascript String vowel()

// Is it a vowel?

String.prototype.vowel = function() {
    const regex = /^[aeiou]$/i;/*from w  ww.jav a2s  . c o m*/
    console.log(this);
    return regex.test(this);

};

console.log('a'.vowel());

Javascript String vowel()

//Implement String#vowel?, which should return true if given object is a vowel, false otherwise.

String.prototype.vowel = function() {
  return /^[aeiou]$/i.test(this);
};

Javascript String vowel()

// http://www.codewars.com/kata/regexp-basics-is-it-a-vowel

String.prototype.vowel = function() {
  return /^[aeiou]$/i.test(this) && !/\n/.test(this);
};

Javascript String vowel()

String.prototype.vowel = function() {
  return /^[aeiou]$/gi.test(this);
};



PreviousNext

Related