Ask coding questions

← Back to all posts
this simple route project is hard help
nanasv (0)

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... ');

" ` "

Comments
hotnewtop
OldWizard209 (1538)

can you please format your code using a pair of three backticks like :

"  ```  "
<CODE IN HERE>
"  ```  "
nanasv (0)

@OldWizard209
"`"

//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... ');
"`"

nanasv (0)

@nanasv
please can I have your user name and tag on discord so that I can add you up

OldWizard209 (1538)

rather I can add you on a team in replit itself. @nanasv

nanasv (0)

@OldWizard209
The route function is still pending no solution yet.
I have used the format the way you demand and waiting for the solution.
Or should I ask on team.

nanasv (0)

@OldWizard209
Sorry to ask silly where should I click to jump to the team. Node.js,or ...

OldWizard209 (1538)

click on this repl wher you added the code:

@nanasv There will be a chat option there on the bottom left also.