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... ');
I moved your question to its own topic because you were asking a question related to your own code for a challenge and were not answering the OP of the other thread. It is always best to create your own thread for you specific question(s). Also, it is advisable to use the Ask for Help button on the challenge, so it auto-populates with your current code and the challenge url, if this relates to the freeCodeCamp curriculum.