Here you need Array . An array is a variable that can contain multiple values and / or elements. You can assign it your values, and then use the [n] selector, where n is a number from 0 (the first element) and 2 (in this case, 2, because you only have 3 variables, so their positions will be 0, 12).
Then, to make the code more understandable, you can use the switch() operator to check the values and execute some code when a certain value is detected.
Here is an example:
function clickButton() { var x = document.myform.mytext.value, values = [13, 17, 19]; switch (x) { case values[0]: case values[1]: case values[2]: alert("hello"); break; default: alert("goodbye"); break; } }
source share