Комментарии:
Thank you very muh for really breaking this topi. you are the best
ОтветитьThank you, I understand it much better now!
Ответитьlove the video😍😍
ОтветитьI wonder how many times I'm going to forget this one.
ОтветитьShalom Mr. K, outstanding explanation!
Thank you
Shalom
What if we want the total of two arguments..like in this case there was only single I.e price
ОтветитьThe concept of reduce method is very well explained because it was difficult to understand the concept of this in the documentation.
Thanks.
LOL - after googling for HOURS(!!!) I finally got it - after just 3min into this video. Damn good explanation! Thank you sooo fkn much!!!
Ответитьlet arr = [
{name:'ram', age:26},
{name:'shyam', age:32},
{name:'mohan', age:42},
{name:'sohan', age:42 }
];
let result = arr.reduce((acc,item) => {
const age = item.age;
if(acc[age] === null);
acc[age] = [];
acc[age].push(item);
return acc;
}, {});
console.log(result);
result: {
'26': [ { name: 'ram', age: 26 } ],
'32': [ { name: 'shyam', age: 32 } ],
'42': [ { name: 'sohan', age: 42 } ]
}
Very well explained, crystal clear. Thanks for this content!
ОтветитьAwesome 🎉 thank you
Ответить❤❤❤❤
ОтветитьI luv your content, but Udacity JS Nanodegree is cheaper than your JS Course
ОтветитьYour hair is always on point 🔥
Ответитьthank u so much
ОтветитьWhat I love about Kyle's teaching style and videos is he first writes the code in another familiar way then converts it into the topic he's about to discuss. Whenever I want to learn something quickly and clearly without fuzz, like Recursion, his videos are my go-to learning material! He breaks it down step-by-step full of detailed explanations. Amazing!
ОтветитьWhile I understood how reduce worked, I didn't quite get why I kept hearing how powerful it was - your object example made it very clear in a short amount of time!
ОтветитьThanks man! Been hating the tasks which force you to use reduce so far.. feels like you randomly try until it somehow works. I really don't get why this feels so awkward to use or understand but your examples were extremely clear and helpful. Perhaps now I can stop dreading the reduce method. 😅
Ответитьvery very very cleaar , thaaank you
Ответитьlove u so much coach👌
ОтветитьThank you
ОтветитьThank you so much! This is so much clearer than other tutorails using acc, cur….
ОтветитьI don't understand what's going on in this line of code
if (groupedPeople[age] == null) groupedPeople[age] = [ ]
groupedPeople[age].push(person)
what's happening in the condition is this suppose to be a one liner if statement? how would this code look like with brackets?
I've watched this video twice, once before ~5 months and now after forgetting what "reduce" does... and im so thankful every time! Thank you!
Ответить"redutthh" method.
Ответить10 minutes of this is so much better than 1,000 hours of understanding the docs
Ответитьit's been a year, I still don't get it :D
ОтветитьThank you for a great and easy to understand explanation
ОтветитьI've watched a fair few videos on reduce, but you have explained this wayyyy better.
Ответить7 the video on reduce in the last 40 mins and this is as simple as you can get...superb. A like and a subscribe from me.
ОтветитьBut in the ages example how he could he use null to say that people does not have this age then start to create new array and push this person with that age value. I did not know that you can use null like this. I thought null is just empty.
Ответитьafter your explanation this is my fav method
ОтветитьI find it useless for limited arrays, it is used by developers only to look smart and because it's trendy. The same functionality is faster and more readable with an old for loop. Reduce method makes sense for streams but it was imported also for collections.
ОтветитьThanks Kyle for your simplified explanation with useful example
ОтветитьHi, I'm kinda new and I don't get the second example. Why does he do groupedPeople[age]? Why there are square brackets? it is not an array, it's an object but he treats it like an array. I think I'm missing something here...
Ответитьthanks so much for this explanation!!! it really helped
ОтветитьI've been trying array methods exercises and they're making me so unmotivated, I can't get a single one right
ОтветитьGood explanation Kyle!
I think the second example should use undefined rather than null, then you can use strictly equals like so:
if (groupedPeople[age] === undefined) groupedPeople[age] = []
i didn't get example 2 can anyone explain it again??
ОтветитьHere is two one-line solutions:
people.reduce((grouped, {age}, i, arr) => ({...grouped, [age]:[...grouped[age] || [], arr[i]]}), {});
people.reduce((grouped, person) => ({...grouped, [person.age]:[...grouped[person.age] || [], person]}), {});
All i gotta say is Thank you mate, you're awesome!
ОтветитьAs always a great lecture. Thanks a lot
ОтветитьOn the second reduce example, how would you reduce that data structure again? For example, lets say there was a third value in the object like height, once you have them sorted by age, could you sort by the height in each age?
Ответить