How can I add an "else" statement to the following dictionary with key/value pairs to handle any sort of ambiguity?
var inputArr = input.match(/[\d.]+/g).map(Number);
var inputAnswer = ""
inputArr.forEach(function(element, index){
var lookUp = {
"1":"611"
"2":"612"
"3":"613"
"":""
};
inputAnswer = lookUp[element];
}
return inputAnswer
});
As you can see, the key/value pairs are only programmed to handle "1","2","3", and "". How can I add another value to it which would return blank string ("") if it is passed any other value? Just want it to be dynamically set up to handle any sort of data. Thanks!