Variable declaration possibilities

is it possible to create a variable that’s defined as any number less than or greater than a specific value?

something like this:

const lowNumber = lowNumber < 0
*although this doesnt work

Hi there,

You can create a random number less than or greater than the value or you can create an array of values less than or greater than the value…

What you’re looking for is probably closer to a boolean expression:

var x = -2; 
const lowNumber = x<0; //Since x=-2, x is less than 0, and lowNumber is true
const highNumber = x>0; //Since x=-2, x is less than 0, and highNumber is false
1 Like

Yes that’s exactly what I’m looking for! Thank you so much!

This topic is solved.