Once again Mosh shows why he's one of the best coding teachers. You make things very clear, because you explain what EVERYTHING is, in laymen's terms. A lot of coding teachers forget they're teaching beginners.
The English is just so perfect for a non-native speaker like me. The explanation is so easy to understand too. Thank you so much, you get my subscription!
It would be great if you explain how the accumulation can be an array or object, and how when instead of chaining map and filter we can use reduce. I guess it's in the complete course.
If you were using an array, you could return an array in the reduce, and spread the accumulator. Then add any new value after. Example: nums = [1,2,3,4,5] const doubledNums = nums.reduce( (acc, num) => [...acc, num*2], [ ]) console.log(doubledNums) // [2,4,6,8,10] Obviosuly a .map could do the same thing but there are more complex examples where it is useful.
@@Xetron1978 … is the spread operator. If you have an array, let’s call x and want to make a new array, let’s call y, that has all the values of x, you can spread x into y. Example: Const x = [1,2,3] Const y = […x] Console.log(y) // [1,2,3] You can also spread objects into objects
Hadn't got used to that reduce method and was struggling for a while, only took me a minute of your explanation to spark a lightbulb in my head and I felt relieved. Thank you.
Thank really. I was making a project. I am adding tips of bills as % to a calculation machine and i need to sum all tips and print. At the end i succeeded by looking to your tutorial. Thanks so much.
i just bought a 100 algorithms course from udemy.com. I prefer the way you teach. You explain everything thoroughly, the course instructor seemed to rush through the videos.
I also think the "old way" is better. The "elegant way" is limited to iteration of type y_n = f(y_{n-1}, x_n) where f is the callback function. There is this new movement in programming where people think old fashion for-loops are ugly code.
Great tutorial, very well explained and easy to follow, I can finally say I understand the reduce method. Thanks you! Hope to see more tutorials like this in the future, like this key word, classes, call, bind, apply, etc.
Literally just spent an hour trying to figure this out from reading on MDN. I understood beforehand how reducing works. I'm familiar with the concept from a few other languages, which implement it more elegantly through lambda expressions. Javascript syntax can be odd at first, and it all came down to simple syntax errors I was making.
You’re the big boss. 😎😎😎 I went through other websites and videos but your explanation was the best. Thank you very much! I had the answer all time at home, since I was subscribed to your channel before. 🤩🤩🤩
actually, it must be accumulator += currentValue but just + works here maybe because of reduce method is holding the current value in memory for every iteration.
Once again Mosh shows why he's one of the best coding teachers. You make things very clear, because you explain what EVERYTHING is, in laymen's terms. A lot of coding teachers forget they're teaching beginners.
Finally... Somebody who explains reduce well. MDN documentation didn't help me.
Just came from MDN 'cause I didnt understant a sheep!
Exactly.
You are very right! MDN didnt help at all...
Ikr he is awesome
So much clarity in 7 minutes video !
Awesome , just understand what is the role of the "Accumulator" and the "Current Value" makes everything very clear. Thank man!
I love he teaches coding very clearly in a short amount of time. He's the best coding teacher.
th-cam.com/video/a_Bfu1XWGmI/w-d-xo.html
The English is just so perfect for a non-native speaker like me. The explanation is so easy to understand too. Thank you so much, you get my subscription!
finally, I can totally understand the reduce method thanks to you, appreciate your channel
It would be great if you explain how the accumulation can be an array or object, and how when instead of chaining map and filter we can use reduce. I guess it's in the complete course.
If you were using an array, you could return an array in the reduce, and spread the accumulator. Then add any new value after. Example:
nums = [1,2,3,4,5]
const doubledNums = nums.reduce( (acc, num) => [...acc, num*2], [ ])
console.log(doubledNums) // [2,4,6,8,10]
Obviosuly a .map could do the same thing but there are more complex examples where it is useful.
@@liamwelsh5565 Hi, I'm very new to coding, may I know why did you add the "..." before acc? I'm not really sure what it does here
@@Xetron1978 … is the spread operator. If you have an array, let’s call x and want to make a new array, let’s call y, that has all the values of x, you can spread x into y.
Example:
Const x = [1,2,3]
Const y = […x]
Console.log(y)
// [1,2,3]
You can also spread objects into objects
How am I only finding your tutorials now. You explain so well. I'm taking you with me for the rest of my Java script journey.
I spent 20 minutes on mdn understanding all this. I got more confused there.Thanks man
This is by far the clearest explanation I've seen on the reduce method so far.. Thanks a lot Mr Mosh..
Hadn't got used to that reduce method and was struggling for a while, only took me a minute of your explanation to spark a lightbulb in my head and I felt relieved. Thank you.
th-cam.com/video/a_Bfu1XWGmI/w-d-xo.html
Finally ... some who explain reduce well .Thanks
I've explored every single line of MDN reference, but I didn't learn as much I could get from you. Appreciate that mate
Boss more blessing to you, love from Nigeria. You just explained all MDN couldn't in minutes
Been looking high and low for a simple explanation of the reduce method, and only now I have found it. Thank you.
Thank really. I was making a project. I am adding tips of bills as % to a calculation machine and i need to sum all tips and print. At the end i succeeded by looking to your tutorial. Thanks so much.
The first tutorial that made me understand reduce method. Thanks.
Having it explained in video form is so much easier for me than reading it. Thank you!
th-cam.com/video/a_Bfu1XWGmI/w-d-xo.html
great explanation Mosh..
[...Array(1000)].reduce((acc, elem) => {
return acc + 'Thanks Mosh ';
}, ['Great Explanation ']);
By far the best explanation of reduce I have gotten haven watch tones of videos and tutorials
Cleanest explanation I've seen so far. You just earned yourself a sub.
Best method of teaching reduce method from complicated to its simplest possible form all under 10mins. You are amazing good sir. Thank you
This video is posted a long time ago, but for the first time i understand reduce. Thanks Mosh!
Mosh is everything a newbie needs!!!
I'm from Brazil, but you explained so well. Thanks a lot!
i just bought a 100 algorithms course from udemy.com. I prefer the way you teach. You explain everything thoroughly, the course instructor seemed to rush through the videos.
Thank you Mosh. This is one of the best explanations about how to use reduce, that I could find on TH-cam.
After watching this higher education, I was finally able to deeply understand it. Thank you!
Thank you Mosh. I wish everyone can explain things as clearly as you.
Explained better than MDN. Good job!
Thank you for breaking this down in detail. Very easy to understand.
You're the BEST Instructor I've ever come across +ProgrammingwithMosh
*sheds a tear* LOL :D -- I can't wait for more JS videos!!!!!
Took me a while to get reduce even after learning all the other iteration methods. Thank you!
Wow this guy is simply the best and you cannot dispute that
Hooray, finally someone explained normally .. thank you very much!
This explanation is way better than the documentation.
Excellent explanation. I was confused how it worked until I saw this. Keep doing what you're doing man!
Can anyone explain why for loop or foreach is "old way" and reduce is more "elegant way"?
I find the"old way" more readable than the "elegant way"
understand the elegant way and use the readable way if you want, after some months you will like to use the elegant way
I also think the "old way" is better. The "elegant way" is limited to iteration of type y_n = f(y_{n-1}, x_n) where f is the callback function. There is this new movement in programming where people think old fashion for-loops are ugly code.
"Just check MDN" does not help. These videos are the only things out there that actually explain anything. Thanks Mosh.
Thank you dude, this is incredible. I wasn't understanding this before watching your video, thank you.
This is super detailed, yet simple to understand, just great!
Best code videos I ever watched. Thank you brother!
Amazingly clear!! Functional Programming is the best ❤️
th-cam.com/video/a_Bfu1XWGmI/w-d-xo.html
one of the best explaination I ever watched
Lovely explaination and lovely Mosh.
We Love You Mosh, From Iran.
This is a better description than coding academy.
as usual, you make coding easy ...your explanation is great
th-cam.com/video/a_Bfu1XWGmI/w-d-xo.html
You are a king in easy explaining
The best teacher so far
This is nice but it'd be great if there was something on how to use reduce when making new objects/arrays
Great tutorial, very well explained and easy to follow, I can finally say I understand the reduce method. Thanks you! Hope to see more tutorials like this in the future, like this key word, classes, call, bind, apply, etc.
Thank you for explaining this right! No one seems to explain the first callback value as the accumulator but yet as the previous value.
I was totally in the dark with this Reduce thing...thanks for explaining🙏 great help 👏👏👏
This is very clear and simple explanation!! Thank you very much 😊
He the best teacher on the internet
Wow! Explained in a super easy way. Thank you.
Thank u for the great explanation
let num = numbers.reduce((a,c) => a+=c ,2)
Mosh, thank you so much! You broke this down into a very easy to understand way.
Thank you. Better than any video out there.
This made my brain hurt a lot less than the lesson I was reading. Thank you!
Man, amazing explanation! So much better than some of the videos and websites I have seen on this topic!
Thank you so much brother,your explanation was very simple and clear
Thank you for making js clear and simple to understand
Finally!!! Well explained in details. You’re a good man
You are the best instructor mosh
Thank you, Mosh. I found this very helpful for grasping the concept of reduce().
Wow, so I was trying to understand this by reading it on MDN and it was just not sinking in. This helped SO much! Thank you good sir.
Literally just spent an hour trying to figure this out from reading on MDN. I understood beforehand how reducing works. I'm familiar with the concept from a few other languages, which implement it more elegantly through lambda expressions. Javascript syntax can be odd at first, and it all came down to simple syntax errors I was making.
Thank you so much for the beautiful explanation of reduce the method.
best coding teacher :)
Such A smooth Explainer
Thank you so much for this tutorial! Love the no-nonsense approach that any layman can pick up on :)
MDN should hire you to do their video explanations. This was great!
You’re the big boss. 😎😎😎 I went through other websites and videos but your explanation was the best.
Thank you very much! I had the answer all time at home, since I was subscribed to your channel before. 🤩🤩🤩
Nice explanation of the Reduce Method of arrays. Thanks, Mosh
{2021-08-14}
Excellent explanation of reduce function.
1:11 prepare your sunglasses
haha! I didn't wish that.
Your way of explaining is nice
Cheers, nice way of explaining things, I always pass ur videos when it pop ups now I watch and it's wonderful.
you have made it simple man ! kudos
thank you for explaning the basic concepts very clear...best explanation
Best... Thank you sir...love from india.♥️
My favourite teacher
Great vid , helped me to finally jump that mental hurdle.
Amazing!!! Thank u for breaking it down and explaining the components . Very helpful.
th-cam.com/video/a_Bfu1XWGmI/w-d-xo.html
Nice and simple. Very well explained
Thank you mosh you explained it perfectly
actually, it must be accumulator += currentValue but just + works here maybe because of reduce method is holding the current value in memory for every iteration.
I don’t even speak English that well and undestood everything! Thanks
wonderful explanation!!! tnx for been there Mosh!!!
interesting ... i like the way u teaching explaining...thank u so much....and keep it up....
Simplicity is always key!
thanks buddy for making concept clear
Wow, so clear. Thanks, Mosh!!
I have tried to do in the old fashion way using for(let i = 0;i
Awesome explanation! Thank you for this!
Brilliantly explained.
this thing was making me pull my hair out, thanks mosh
Great video on reduce(). Thankyou you have clear all my queries and doubts
very easy to understand by good explanation