1
2
3
4
5
6
7
8
9
export const getNextDir = (grammar, index) => {
if (index >= grammar.length - 1) return false;
if (grammar[index + 1] == "^") return "UP";
if (grammar[index + 1] == "V") return "DOWN";
if (grammar[index + 1] == "<") return "LEFT";
if (grammar[index + 1] == ">") return "RIGHT";
if (grammar[index + 1] == "]") return false;
return false;
};
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
October 23, 2023