I have a search function that works fine on its own. Its purpose is to search for a key in a JSON object and get the value of it.
function findVal(object, key) {