Match Numbers and Letters of the Alphabet regex

Tell us what’s happening:

Hi, I’m having difficulty understanding this series of exercises. I know my problem is with the last line, but what exactly is the issue I can’t tell. Can anyone assist?

Your code so far


let quoteSample = "Blueberry 3.141592653s are delicious.";
let myRegex = /h-s2-6/ig; // Change this line
let result = myRegex.test(quoteSample); // Change this line

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/match-numbers-and-letters-of-the-alphabet

Actually what you are doing here is correct except the last line. your last line is testing weather the regex pattern is present or not in the given string. it will return a boolean value. But the test expects you to return certain number of itemss so

let quoteSample = "Blueberry 3.141592653s are delicious.";
let myRegex = /[h-s2-6]/ig; // Change this line
let result = quoteSample.match(myRegex); // Change this line

change the last line like this

Take a look again at the explanations on the left and how they use a range. Your regex is not a range, but just the characters h, -, s, 2, - and 6. The other problem is that they want you to match your regex, but you are using test. The difference is that test is returning a boolean, and match is returning an array with all the characters from the sample that fit the regex. You can check the difference by using a console.log on result and see the difference in the developer console.