hello, am having issue completing this little route project.
If I run the first function independent it has no problem, but calling the function in the next function it display error.that prop can’t iterate what should I do please.
//Array of integers for searching maximum integer
const mixItems = [2,6,96,35,6];
//object
const itemsObj = {
"Biscuits": 12,
"Bread": 94,
"Danon_milk": 16,
"Golden_morn": 50
};
//Helper function to find the maximum integer
function eventHandler(par){
let maxValSearch = [];
maxValSearch = [...par];
var maxVal = par.reduce(function(initEl,finEl){
maxValSearch = ([initEl,finEl]);
return Math.max.apply(null,maxValSearch);
});
return maxVal;
}
eventHandler(mixItems);
//other function
const itemsFunction = function(obj,prop){
totalSellParItem = " ";
for(let i in obj){
if(obj.hasOwnProperty(i)){
prop = i;
result = obj[prop];
if(result !== undefined){
totalSellParItem = result;
let totalBisPrice = eventHandler();
return totalSellParItem += totalBisPrice;
}else {
return "result of the property not found ";
}
}else {
return "this property is not found ";
}
}
return totalSellParItem;
}
let propPrompt = prompt('enter the property here');
const eventHandlers = itemsFunction(itemsObj,propPrompt)
window.alert(eventHandlers +":"+ 'searching... ');