Javascript Array check element via Regular Expressions

Description

Javascript Array check element via Regular Expressions


let elemSet = new Array("**",123,"aaa","abc","-",46,"AAA");

// testing function 
function textValue (element,index,array) {
   let textExp = /^[a-zA-Z]+$/;
   return textExp.test(element);
}

// run test//from  w w  w  .  j av  a  2  s. co  m
console.log(elemSet.every(textValue)); // false

let elemSet = new Array("**",123,"aaa","abc","-",46,"AAA");

// run test
console.log(elemSet.some(textValue)); // true



PreviousNext

Related