JavaScript Practice: Data Types, Conditional, Functions (Problem #3)

Create a function numberDigits() that takes the variable x as its only parameter. If the variable x is between 0 and 9, return the string 'One digit: N ' , where N is the value of x . If the variable x is between 10 and 99, return the string 'Two digits: N ' , where N is the value of x . Any other value of x , including negative numbers, return the string 'The number is: N ' , where N is the value of x .

The link to the problem (

My code would return unexpected results. I’m obviously doing something wrong here. Some help would be appreciated!

// Create function here
function numberDigits(x) {
if(x => 0 && x <= 9) {
return One digit: ${x};
else if(x => 10 && x <= 99) {
return Two digit: ${x};
else {
return The number is: ${x};


You’re using => instead of <=, so it’s not working the way you want.


console.log(x => 0);

would output [Function] instead of true or false

Also, to pass the check, be sure to follow exactly what text they want in the output. You have “Two digit” instead of “Two digits

That solved it. Thanks!