src/utils/isCharConsonant.js
/**
 * Tests a character and an english consonant. Returns true if the char is a consonant.
 * @param  {String} char
 * @param  {Boolean} [includeY=true] Optional parameter to include y as a consonant in test
 * @return {Boolean}
 */
Tests a character and an english consonant. Returns true if the char is a consonant.
@param  {String} char
@param  {Boolean} [includeY=true] Optional parameter to include y as a consonant in test
@return {Boolean}
Tests a character and an english consonant . Returns true if the char is a consonant . @param { String } char @param { Boolean } [ includeY = true ] Optional parameter to include y as a consonant in test @return { Boolean }
function isCharConsonant(char = '', includeY = true) {
  if (isEmpty(char)) return false;
  const regexp = includeY ? /[bcdfghjklmnpqrstvwxyz]/ : /[bcdfghjklmnpqrstvwxz]/;
  return char.toLowerCase().charAt(0).search(regexp) !== -1;
}
function isCharConsonant ( char = '' , includeY = true ) { if ( isEmpty ( char ) ) return false ; const regexp = includeY ? / [bcdfghjklmnpqrstvwxyz] / : / [bcdfghjklmnpqrstvwxz] / ; return char . toLowerCase ( ) . charAt ( 0 ) . search ( regexp ) !== - 1 ; }
Tests a character and an english consonant.
Tests a character and an english consonant .