Daily Coding Challenge - Base Check

Tell us what’s happening:

Does the freeCodeCamp JS compiler not work with regex’s, becasue my code should work perfectly fine, but it doesn’t.

Your code so far

function isValidNumber(n, base) {

  binaryRegex = /^[0-1]+$/; 
  octalRegex = /^[0-7]+$/
  base10Regex = /^[0-9]+$/; 
  hexRegex = /^#?([a-f0-9]{6}|[a-f0-9]{3})$/i; 
  base36Regex = /^[0-9a-z]+$/i; 

  /*

  switch(base){
    case 2: 
    return binaryRegex.test(n); 

    case 8:
    return octalRegex.test(n); 

    case 10: 
    return base10Regex.test(n); 

    case 16: 
    return hexRegex.test(n); 

    case 36: 
    return base36Regex.test(n);  

    default: 
    return "Error"
  }*/

  if(base == 2){
    return binaryRegex.test(n); 
  }
}

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36

Challenge Information:

Daily Coding Challenge - Base Check
https://www.freecodecamp.org/learn/daily-coding-challenge/2025-08-12

console.log(isValidNumber("10101", 2))

What do you see in the console when you add this to the bottom of your code?