Checking Keywords in Array

StackOverflow Answer

by bhatnagar018

JavaScript

var words = ['abstract', 'arguments', 'await', 'boolean',
  'break', 'byte', 'case', 'catch',
  'char', 'class', 'const', 'continue',
  'debugger', 'default', 'delete', 'do',
  'double', 'else', 'enum', 'eval',
  'expor', 'extends', 'false', 'final',
  'finally', 'float', 'for', 'function',
  'goto', 'if', 'implements', 'import',
  'in', 'instanceof', 'int', 'interface',
  'let', 'long', 'native', 'new',
  'null', 'package', 'private', 'protected',
  'public', 'return', 'short', 'static',
  'super', 'switch', 'synchronized', 'this',
  'throw', 'throws', 'transient', 'true',
  'try', 'typeof', 'var', 'void',
  'volatile', 'while', 'with', 'yield'
];
var length = words.length,
  input = prompt("enter keywords"),
  found = false;
  console.clear();
for (i = 0; i < length; i++) {
  if (input == words[i]) {
    found = true;
    console.log("Found");
    break;
  }
}

if (!found) {
  console.log("Not Found");
}