₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,082 members, 8,420,207 topics. Date: Thursday, 04 June 2026 at 01:42 PM

Toggle theme

Debug This Code At Your Spare Time. - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingDebug This Code At Your Spare Time. (979 Views)

1 Reply (Go Down)

Debug This Code At Your Spare Time. by Maskyy(op): 4:13am On Jan 11, 2020
someone should check out this my js code. ERROR: instead of 3 iteration output, it output 9 iterations. just bordering me since.


let z = [
{id : 1 , age : 20},
{id : 2 , age : 15},
{id : 3 , age : 30}
]

let Obj = {
oder1:{
id : 1,
name : 'Ben',
club : 'chelsea',
food : 'pie',
stat : 500
},
oder2:{
id : 4,
name : 'Bolu',
club : 'ManU',
food : 'saws',
stat : 700
},

oder3:{
id : 2,
name : 'Julie',
club : 'ManU',
food : 'saws',
stat : 700
}

}

z.filter(value => {
for (const key in Obj) {
if (Obj.hasOwnProperty(key)) {
const element = Obj[key];
value.id===element.id ? console.log(`hi ${element.name}. Id is correct`) : console.log(`invalid Id ${!String()}`);
}
}});
Re: Debug This Code At Your Spare Time. by gbolly1151(m): 8:29am On Jan 11, 2020
I suggest to save it again and run
Re: Debug This Code At Your Spare Time. by peterincredible: 9:19am On Jan 11, 2020
array.filter() must return a boolean you are not returning anything guy put your return in the for() state ment where your checked if return element.id === value.id ? whatever : whatever

i hope it works cause no light for me to test wetin i talk but i just observe u didnt return anything
Re: Debug This Code At Your Spare Time. by Maskyy(op): 9:00am On Jan 12, 2020
it as being fixed. Thanks to your responds.
1 Reply

Please Who Can Help Me Debug This Testing Code?Someone, Please Help Debug This CodeCan Somebody Help Me Debug This?234

A Quick Guide To Opencart PWA Mobile App DevelopmentLaptops For Sale.. Affordable As Always !I Need Developers