In my website I have a terminal where the user can enter "man lochlann" to return a description on what the command 'lochlann' does.
This input is of Type String. I would like to check if this String is a valid key in the dictionary 'MAN'.
var MAN_PRIVATE = {
lochlann: "LOCHLANN<BR>lochlann - Returns a description for the best Software Developer to have ever lived<br>argument - NOT REQUIRED",
mtu: "MTU<BR>mtu - Returns a description on Munster Technological University<br>argument - NOT REQUIRED",
}
var MAN_PUBLIC = {
help: "HELP<br>help - provides the user with information on how to use the terminal<br>argument - NOT REQUIRED",
bin: "BIN<br>bin - returns a list of all acceptable commands.<br>argument - NOT REQUIRED",
}
MAN = Object.assign({}, MAN_PRIVATE, MAN_PUBLIC);
command = "help";
executeMan(command);
function executeMan(command) {
if (command in MAN) { //this condition returns true
console.log(MAN.help); //this works
console.log(MAN.command); //this does not work - returns 'undefined'
}
}