I need to be able to input a value and get the value of the input out of an array. the problem is the array is made of objects and the input is a string, and I tried searching the internet and trying to solve the problem myself, but I could not find out how to solve the problem.
//object array
var mods = {
quick:{speed:10},
deadly:{damage:10,speed:10},
agile:{speed:10,crit:3},
murderous:{damage:7,speed:6,crit:3},
slow:{speed:-15},
sluggish:{speed:-20},
lazy:{speed:-8},
annoying:{damage:-20,speed:-15},
nasty:{damage:5,speed:10,crit:2,kb:-10}
};
function calculateResult() {
//these are strings
var modName = document.getElementById("modName").value;
var modType = document.getElementById("modType").value;
//it doesnt like mixing strings and objects
//mod is an object, modName and modType are strings
document.getElementById("result").innerHTML = mods.modName.modType
}
<input id="modName">
<input id="modType">
<button onClick = "calculateResult()">result</button>
<h1 id=result>a</h1>