Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

split function not working in if statment Javascript

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

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading