I want something like the following in Javascript
if str.charAt(index) (is in the set of) {".", ",", "#", "$", ";", ":"}
Yes, I know this must be simple, but I can't seem to get the syntax right. What I have now is
theChar = str.charAt(i);
if ((theChar === '.') || (theChar === ',') || (theChar === ... )) {
// do stuff
}
This works, but there must be a better way.
Edit: I did this, but not sure if it's GOOD or not:
var punc = {
".":true,
",":true,
";":true,
":":true
};
if (punc[str.charAt[index]) { ...