So I'm trying to make a if statement with many possibilities, but what ended up happening is now I have WAY too many || in my if.
I thought maybe it would be possible to throw all of the possible values into a array, and then only do condition == array or something.
Anyway here's my code. Please help. Thanks in advance.
<body>
<input id="userInput">
<button onclick="Submit()">Submit</button>
<script>
function Submit() {
var input = document.getElementById("userInput").value;
if (input == "random text" || input == 3 || input == "more random text"
|| input == false || input == "another random string.")
{
// Do Something
}
</script>
</body>
typeof inputwill always be"string". You'll never get array or boolean or anything else.indexOfw3schools.com/jsref/jsref_indexof.asp