var text = "Q!123"; //Setting variable
if(isNaN(text.split('')[text.indexOf("!") 1]) != true){ //Checking if character after the ! is a number
return true; //Return true if true
}else{
return false; //Return false if false
}
At the if statment where I have text.split(''), im not able to use it whilst grabbing a character from the array
CodePudding user response:
you write this match statement in if to check after '!' is number or not
var text = "Q!123";
let match = text[text.indexOf("!") 1].match(/[0-9]/)
console.log(match)