codingman
April 28th, 2012, 12:22 AM
Say, I have a var foo and I want to check if the value of the variable is a member of a set of numbers 1, 3, 4, 6, 7. How would I do that? Any help would be appreciated :)!
Dimarchi
April 28th, 2012, 04:34 PM
Perhaps these links will prove to be educational:
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/indexOf
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf
In short, if the answer is anything else than -1 it is in that set of numbers.
Powered by vBulletin® Version 4.2.2 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.