Help me understanding switch statement here

Tell us what’s happening:
Hi! I don’t understand why this switch statement is not working. What’s my error here? Thanks!
Your code so far

function telephoneCheck(str) {
let digits = str.replace(/\D/g, "");
switch (digits){
  case digits.length < 10:

telephoneCheck("123**&!!asdf#"); // returns undefined
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:86.0) Gecko/20100101 Firefox/86.0.

Challenge: Telephone Number Validator

Link to the challenge:

That’s not how a switch statement works. I would review how a switch works:

The cases have to be values that the variable digits are strictly matched against. A switch is not exactly interchangeable with an if-else statement.

1 Like