In processing.js i used the following code to find a character position within the string scale:
int whatKey()
{
int i;
for (i=0; i<EOS; i++)
{
if (scale.charCodeAt(i)==key) return i;
}
return -1;
}
How can I do this in p5.js? I tried with match() but don't know the syntax.
Answers
Works fine. Thanks a lot!
But... "scale" cannot be used as variable. It worked in processing but not in p5.js so I had to change it to something else. Is there a list of reserved keywords for p5.js ?
Here: http://p5js.org/reference/
In JavaScript, even functions are referenced in variables. Therefore, if we reassign a variable w/ the same name of some existing function, it is erased! :-SS