How to check if a variable has a value from an array

Twine Version: 1.4.2
Story Format: Sugarcube 2.35

Hi.
I know maybe it’s a pretty noob question, but I haven’t found the answer.
I have an array with several random numbers and I need to track if the value of another variable equals one of the numbers of that array.
Example:

<<set $array to [2, 8, 13, 24, 35, 46]>>
<<set $number to random (1, 50)>>

I tried:

<<if $number eq $array>> You got a number right <</if>>

and also

<<if $number is either ($array)>> You got a number right <</if>>

But nothing worked.
I’m sorry if this has already been answered, but I haven’t found it.

You want the <Array>.includes() method. For example:

<<if $array.includes($number)>> You got a number right <</if>>

You use the <Array>.includes() function to check if an Array includes a specific value. The documentation includes a number of examples, the following one caters for your specific use-case.

<<set $array to [2, 8, 13, 24, 35, 46]>>
<<set $number to random (1, 50)>>

<<if $array.includes($number)>> You got a number right <</if>>

Worked fine.
Thank you very much TheMadExile and Greyelf.