JavaScript Practice: Data Types, Conditional, Functions

Hey guys, I can’t figure out what’s wrong with this code, can anyone help me out?

It only outputs the 'one digit string.

const numberDigits = (x) => {
if (x >= 0 || x <= 9) {
return One digit: ${x}
} else if (x >= 10 || x <= 99) {
return Two digits: ${x}
} else {
return The number is: ${x}


You are close, but not quite there yet

lets say I have 1000, then the if condition looks like this:

if ( 1000 >= 0 || 1000 <= 9)

Resolving the conditions gives us:

if (true || false )

Which will result in true.

Seems you want both conditions to be met, not one of the condition. Which operator do we need for this?

That would be &&, it all works now, thx for helping out!

If you found any wisdom in my answer, I hope this wisdom is learning about debugging or walking through code. And not: should be && operator

To be honest, I’m still having quite a lot of trouble remembering the different operators and their functions, so what it actually taught me, was that I need to read up more on how operators impact the code.

1 Like