Match all numbers and letter

In this challenge the “Run the Tests” step disagrees with the code shown below.
Request a solution for this issue.

Console Output and js Code below:

Console Output:
// running tests
Your regex should find 31 alphanumeric characters in the string The five boxing wizards jump quickly.
Your regex should find 32 alphanumeric characters in the string Pack my box with five dozen liquor jugs.
Your regex should find 30 alphanumeric characters in the string How vexingly quick daft zebras jump!
Your regex should find 36 alphanumeric characters in the string 123 456 7890 ABC def GHI jkl MNO pqr STU vwx YZ. // tests completed // console output 31

Code:

let quoteSample = "The five boxing wizards jump quickly.";
let alphabetRegexV2 = /\w+/g; // Change this line
let result_arr = quoteSample.match(alphabetRegexV2)
let result = 0;
for (let i=0; i<result_arr.length;i++){
result += result_arr[i].length;
}
console.log(result)

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36

Challenge: Match All Letters and Numbers

Link to the challenge:

It wants the characters, not the words.

let quoteSample = "The five boxing wizards jump quickly.";

let reg1 = /\w+/g; // Change this line
let reg2 = /\w/g; // Change this line

let result1 = quoteSample.match(reg1).length;
let result2 = quoteSample.match(reg2).length;

console.log(result1) // 6
console.log(result2) // 31

Hi lasjorg

Thank you for sharing this example.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.