I think this must be work.
const keys = [
{ "keywords": "set,on,increease,decrease,low,medium,high,forward,backward", "commands": "SET" },
{ "keywords": "get,access,retrieve", "commands": "GET" },
{ "keywords": "run", "commands": "RUN" },
{ "keywords": "stop", "commands": "STOP" }
]
function check(value) {
// On every value on keys get index
for (let i in keys) {
// Get key from keys with index value
const key = keys[i];
// Check if is matching
if (key.keywords.split(',').includes(value))
// If successfuly matching is found return commands value
return key.commands;
}
// If any result doesnt returned, return null.
return null;
}