Maybe I am missing something but this particular test requires one to use the short hand charcter class \w
to match all alphanumerics in the quote and thereafter count them.
Trouble is the expected answers want the sum total of all characters in the string my solution is rejected and the provided solution in the help section is wrong because the match()
string method will break the string into words and return the array therefore
let result=quoteSample.match(alphabetRegexV2).length;
will return an array of length 6
This is the solution provide which I have tested and still returns a wrong value
let quoteSample = "The five boxing wizards jump quickly.";
let alphabetRegexV2 = /\w+/gi; // Change this line
let result = quoteSample.match(alphabetRegexV2).length;
This is my proposed
let quoteSample = "The five boxing wizards jump quickly.";
let alphabetRegexV2 = /\w+/gi; // Change this line
let result = quoteSample.match(alphabetRegexV2).length;
let alphaCount=(array)=>{
let total=0;
for(let i=0;i<array.length;i++){
total+=array[i].length;
}
return total;
}
alphaCount(result);
Which counts the individual charcters in the string. Now maybe there is a way to achieve this by the employ of regular expressions only so if you have any ideas please help. Thank you
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/match-all-letters-and-numbers