Learn JavaScript Array Reduce In 10 Minutes

Learn JavaScript Array Reduce In 10 Minutes

Web Dev Simplified

2 года назад

198,697 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

JohnWell Group
JohnWell Group - 30.10.2023 01:09

Thank you very muh for really breaking this topi. you are the best

Ответить
Galih A
Galih A - 06.10.2023 21:33

Thank you, I understand it much better now!

Ответить
MD Rabiul Akand
MD Rabiul Akand - 28.09.2023 09:01

love the video😍😍

Ответить
Diffuusio
Diffuusio - 13.09.2023 12:22

I wonder how many times I'm going to forget this one.

Ответить
John Dodge
John Dodge - 07.09.2023 02:07

Shalom Mr. K, outstanding explanation!
Thank you

Shalom

Ответить
Shivraj Darki
Shivraj Darki - 27.08.2023 14:47

What if we want the total of two arguments..like in this case there was only single I.e price

Ответить
Vivek Modi
Vivek Modi - 26.08.2023 12:35

The concept of reduce method is very well explained because it was difficult to understand the concept of this in the documentation.
Thanks.

Ответить
freudinsky
freudinsky - 10.08.2023 18:00

LOL - after googling for HOURS(!!!) I finally got it - after just 3min into this video. Damn good explanation! Thank you sooo fkn much!!!

Ответить
Ajeet Kumar
Ajeet Kumar - 06.08.2023 19:47

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 } ]
}

Ответить
Edison Seas
Edison Seas - 30.07.2023 07:12

Very well explained, crystal clear. Thanks for this content!

Ответить
yahel sasson
yahel sasson - 29.07.2023 13:20

Awesome 🎉 thank you

Ответить
Psycho op
Psycho op - 26.07.2023 06:59

❤❤❤❤

Ответить
Helal Yehia
Helal Yehia - 14.07.2023 07:18

I luv your content, but Udacity JS Nanodegree is cheaper than your JS Course

Ответить
samichpower
samichpower - 07.07.2023 19:20

Your hair is always on point 🔥

Ответить
Andrew Essam
Andrew Essam - 06.06.2023 17:17

thank u so much

Ответить
gary finegan
gary finegan - 25.05.2023 12:10

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!

Ответить
TheDanthelion
TheDanthelion - 19.05.2023 18:46

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!

Ответить
filipcza2
filipcza2 - 16.05.2023 19:40

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. 😅

Ответить
 Mashael
Mashael - 01.05.2023 06:40

very very very cleaar , thaaank you

Ответить
Indra Darta
Indra Darta - 30.04.2023 14:21

love u so much coach👌

Ответить
theRanchKeeper OD!!
theRanchKeeper OD!! - 20.04.2023 10:33

Thank you

Ответить
Beepy Beepy
Beepy Beepy - 19.03.2023 11:31

Thank you so much! This is so much clearer than other tutorails using acc, cur….

Ответить
Vithursan
Vithursan - 19.03.2023 04:43

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?

Ответить
Adem Layes
Adem Layes - 28.02.2023 23:53

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!

Ответить
NoodyTuned
NoodyTuned - 20.02.2023 21:26

"redutthh" method.

Ответить
InsertYourself
InsertYourself - 08.02.2023 06:00

10 minutes of this is so much better than 1,000 hours of understanding the docs

Ответить
Sam
Sam - 07.02.2023 17:19

it's been a year, I still don't get it :D

Ответить
J V
J V - 06.02.2023 22:06

Thank you for a great and easy to understand explanation

Ответить
Nabil Elidrissi
Nabil Elidrissi - 02.02.2023 17:36

I've watched a fair few videos on reduce, but you have explained this wayyyy better.

Ответить
Sun 197895
Sun 197895 - 25.01.2023 23:30

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.

Ответить
Rayyan
Rayyan - 24.01.2023 19:35

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.

Ответить
dark lord
dark lord - 10.01.2023 05:44

after your explanation this is my fav method

Ответить
Paul Calinovici
Paul Calinovici - 04.01.2023 01:01

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.

Ответить
Tanvir Hasan Monir
Tanvir Hasan Monir - 02.01.2023 18:56

Thanks Kyle for your simplified explanation with useful example

Ответить
Vlad Horbachenko
Vlad Horbachenko - 16.12.2022 22:24

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...

Ответить
drey moreau
drey moreau - 14.12.2022 23:21

thanks so much for this explanation!!! it really helped

Ответить
isa moraes
isa moraes - 08.12.2022 15:32

I've been trying array methods exercises and they're making me so unmotivated, I can't get a single one right

Ответить
MX
MX - 05.12.2022 01:11

Ответить
SquaredIndex
SquaredIndex - 30.11.2022 15:17

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] = []

Ответить
Abhay Kumar Singh
Abhay Kumar Singh - 29.11.2022 20:30

i didn't get example 2 can anyone explain it again??

Ответить
Magnus Fohlström
Magnus Fohlström - 21.11.2022 06:38

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]}), {});

Ответить
Odilanma Evidence
Odilanma Evidence - 04.11.2022 23:19

All i gotta say is Thank you mate, you're awesome!

Ответить
Chandrachur Mukherjee [JU CSE]
Chandrachur Mukherjee [JU CSE] - 02.11.2022 08:34

As always a great lecture. Thanks a lot

Ответить
DerpFisk0151
DerpFisk0151 - 31.10.2022 22:20

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?

Ответить