My objective is to analyze a string in order to identify the presence of lowercase letters or numbers, and then add that specific letter or number to an array.
for(let i = 0; i < datearg.length; i++)
{
log.info(datearg.charAt(i));
if(/[a-z]/.test(datearg.charAt(i))) letter_num++; letters.push(datearg.charAt(i));
if(/[0-9]/.test(datearg.charAt(i))) number_num++; numbers.push(datearg.charAt(i));
}
It seems like both if statements consistently return true, leading to all characters from datearg being included in the arrays. Can anyone help shed light on why this is happening?