16.7: Array Functions: reduce() - Topics of JavaScript/ES6

Поделиться
HTML-код
  • Опубликовано: 1 июл 2024
  • In this video, I cover the JavaScript array function reduce().
    🎥 Next Video: • 16.8: Array Functions:...
    🔗 MDN's Array Documentation: developer.mozilla.org/en-US/d...
    🚂 The Coding Train website: thecodingtrain.com/
    💖 Support this channel on Patreon: / codingtrain
    🛒 To buy Coding Train merchandise: www.designbyhumans.com/shop/c...
    📚 Book recommendations: www.amazon.com/shop/thecoding...
    💻 github.com/CodingTrain/Rainbo...
    🎥 For an Introduction to Programming: • Start learning here!
    🎥 For More Coding Challenges: • Coding Challenges
    🔗 p5js.org/
    🔗 processing.org
    📄 Code of Conduct: github.com/CodingTrain/Code-o...

Комментарии • 275

  • @Edzward
    @Edzward 5 лет назад +215

    "I reduced myself to talk about reduce()" 10/10 teacher.

    • @CameronChardukian
      @CameronChardukian 5 лет назад +1

      Hahaha

    • @thaitranxuan597
      @thaitranxuan597 3 года назад

      i touch my lit- sis like that ..now i pain too.

    • @clevermissfox
      @clevermissfox 6 месяцев назад +1

      He’s the best! So endearing! His enthusiasm is contagious

  • @volfegan
    @volfegan 6 лет назад +131

    1st time I actually understood reduce(). I always used the for loops to find min or max of something, but a new world opens.

    • @jordyleffers9244
      @jordyleffers9244 4 года назад +2

      Yup, I'm going to be busy rewriting lots of stuff!

  • @aslahphussain
    @aslahphussain 3 года назад +9

    what's best about his way of teaching is that he's learning with us!

  • @h2oarindam789
    @h2oarindam789 2 года назад +7

    this guy is sooooo freaking awesome....I can't imagine myself confused after watching any of his videos no matter how difficult the topic is. Hoping you expand content to cover even more concepts and languages. best of luck!!

  • @emmythepixi
    @emmythepixi 5 лет назад +21

    Goddamn, I'm so glad I found your channel! I was so freaking confused about arrow function ternary operator syntax and you explained it in a way that was so easy to understand.

  • @climbers1376
    @climbers1376 5 лет назад +23

    Arrays:
    0:47-1:18 coding traditional summation function
    1:55-6:06 how reduce function works
    6:06-7:13 reducing code (ES6)
    7:29-9:28 coding traditional max function
    9:28-12:50 reducing code... 10:02-11:40 ... further with ternary operator
    13:04-13:49 reduce's "assumed initial value"

  • @grants5036
    @grants5036 3 года назад +1

    This dude is out of breath he is so hype. Love it! I understand you perfectly where I couldn't elsewhere.

  • @Nonsense116
    @Nonsense116 6 лет назад +1

    This seems to be the best explanation I've found so far. Thank you!

  • @sadhlife
    @sadhlife 6 лет назад +124

    I can't stop laughing at the intro XD

    • @dappermink
      @dappermink 6 лет назад +5

      Tushar Sadhwani HELLO I'M TINY

  • @milkdrom3da
    @milkdrom3da 2 года назад +1

    This has been an amazing experience . I love how you broke everything down, i was so confident with the syntax at first but seeing you wait the function first and then break it down and put it into the reduce parameter really helped. Thank you so much for this video-!!!!!!

  • @346ask
    @346ask 3 года назад +1

    You explained this so well, I was trying to wrap my head around it reading the documentation and couldn't understand it. I almost gave up completely. Thank you so much.

  • @you_gotit_bud
    @you_gotit_bud 6 лет назад +1

    Thank you for doing what you do. As someone who is switching careers and trying to get into school, I felt genuinely lost until I stumbled upon The Coding Train. I'm all aboard buddy, keep chugging.

  • @alexhaid626
    @alexhaid626 5 лет назад +1

    Thank you so much! Finally, I got what reduce function is all about and how it works!

  • @vinubox
    @vinubox 4 года назад

    People with deep knowledge will explain things as simple as possible, you are an example

  • @celina6204
    @celina6204 3 года назад

    I love how you're learning with us! You always say exactly what I'm thinking

  • @Medi0cr3-
    @Medi0cr3- 3 года назад

    these are great videos. you're goofy as all can be, but the way you make errors and then go through why the error is there and you explain the error and also explain the fix. This helps me out so much. good work

  • @Matt-tn2on
    @Matt-tn2on Год назад

    Everyone one of this guys videos is therapeutic on a level that’s hard to describe. Pure love…

  • @charmainetabilas3132
    @charmainetabilas3132 5 лет назад +1

    This was super helpful and I think you did a great job explaining it! It made the MDN documentation make sense.

  • @basselturky4027
    @basselturky4027 Год назад

    I never seen better explanation for reduce function.
    Thank you so much.

  • @asaadmahmood7674
    @asaadmahmood7674 5 лет назад

    Just started watching your videos yesterday, have developed into a really big fan!

  • @ritchieharrison8808
    @ritchieharrison8808 4 года назад

    thank you so much man!!! I was looking for the logic explanation at 12:36 for the past 4 hours but nobody could make it clear as you did. Now it's clear as a day.Thanks again!!! Take care!!!

  • @selfmadetool
    @selfmadetool 4 года назад +1

    Thank you, man! The internet has changed the way programmers learn!

  • @SungjinHa
    @SungjinHa 3 года назад

    Found my new favorite code explainer. Thinks the way I think when I'm trying to figure stuff out.

  • @BlockCylinder
    @BlockCylinder 3 года назад

    It's clicking for me today.
    Thank you for all of your videos.

  • @liamoswald6429
    @liamoswald6429 5 лет назад +2

    first time I've seen the outro and it made me smile so much!

  • @agusisas5742
    @agusisas5742 3 года назад

    Far way the best teaching videos I ever seen! You explain in such funny way!!
    I love your videos

  • @--Dipanshu--
    @--Dipanshu-- 3 года назад

    He is truly a dedicated and passionate teacher

  • @Sun1ive
    @Sun1ive 6 лет назад +1

    the best video so far that i saw about reduce. thanks

  • @matthewblasco4720
    @matthewblasco4720 2 года назад

    THANK GODDDDDDD!! I WAS RACKING THE WRITTEN DOCUMENTATIONS WITH NO RESULT FOR 5 HOURS!!! AND YOU ANSWERED ME FOR 14 MINS!!

  • @faribadadko5694
    @faribadadko5694 3 года назад

    Great explanation! it STICKS now! Thank you!

  • @vivekraj9875
    @vivekraj9875 4 года назад +1

    I love the way of your teaching👌👌,,Best Teacher🏆

  • @kieran2347
    @kieran2347 3 года назад

    This is the first ever video I've come across that explains the exact concept and how it works, step by step, oh man why didnt I find you and this video much sooner, I'm subscribed lol. In struggling with JS alot fyi and look forward to checking all your videos. Thanks man

  • @noa_430
    @noa_430 3 года назад

    I love this. You're really entertaining and I'm learning so much!!!!

  • @RameenFallschirmjager
    @RameenFallschirmjager 4 года назад +1

    Daniel, the crazy uncle that everyone needs!

  • @ga7853
    @ga7853 4 года назад +1

    I really really like your video, thank you so much for the efforts you had put in this video to make it so clear.

  • @alandemir568
    @alandemir568 3 года назад

    I really liked this video, already watched it a few times all the way through. Thanks for the great explanations, it's great how you show your train of thought and all the steps. Your level of crazy is much appreciated also.

  • @dr__ey
    @dr__ey Год назад

    thanks so much for all these videos on array methods!!!! helps make them make sense

  • @emreibrahim8504
    @emreibrahim8504 Год назад

    Great explanation. Its the hardest built in function anyway because it can be used in various problems

  • @GokulRG
    @GokulRG 5 лет назад

    Man, thanks for this! No book explains this properly!! Guess I jumped on the coding train by subscribing :)

  • @abubalo
    @abubalo 2 года назад +1

    Smoothest intro I have ever seen.

  • @ytdevs
    @ytdevs 2 года назад

    Thank you! 🙏💕, it took me years to understand this until I watched your video

  • @jeremyrubio1531
    @jeremyrubio1531 2 года назад +3

    12:32 is really awesome. Great explanation, thanks for sharing your knowledge and it's funny to think that you're learning with us but you can make an app in 15 mins lol.

  • @linahmuhonja4128
    @linahmuhonja4128 Год назад

    Nice tutorial I am so confident about the then jargon reduce () method.

  • @ElderESG
    @ElderESG 2 года назад

    One of the best, if not the best out there. Thank you

  • @sol3cito33
    @sol3cito33 3 года назад

    Thank you so much for this one! I was struggling with reduce() until now but not anymore!

  • @ericrovell1970
    @ericrovell1970 5 лет назад +3

    The best intro I have even seen in my life🤣

  • @80Vikram
    @80Vikram 4 года назад

    Thanks to youtube and people like you; anyone across globe is getting best quality knowledge absolutely free of cost.

  • @sydneymadope
    @sydneymadope 3 года назад

    Unmatched energy! 👏🏾

  • @richardramos7267
    @richardramos7267 6 лет назад

    The only video of yours that I grasp, I'm improving maybe ?.. Your other video is too advance for me, I want to be like you.. You are such a genius.

  • @jacintomichaelpalaroan5615
    @jacintomichaelpalaroan5615 5 лет назад

    Your video helped me understand reduce. thanks a lot!

  • @sanukumar306
    @sanukumar306 3 года назад

    Best explanation technique ever seen 👍🏻

  • @joshrandall3663
    @joshrandall3663 4 года назад

    What a solid explanation. Thank you! Love your videos :D!

  • @starlessnight1164
    @starlessnight1164 3 года назад

    This looks like a really promising channel to learn, thank you.

  • @Amal-qo6kx
    @Amal-qo6kx 4 года назад

    it was challenging for me to understand reduce() you are my favorite teacher ever :D I enjoyed your video and I actually learned, thanks man

  • @nate9550
    @nate9550 5 лет назад +1

    Glad I found your channel, really nice and helpful video! :D

  • @timeowilliams4620
    @timeowilliams4620 3 года назад

    Outstanding job and explanation!

  • @vitorguimaraes9101
    @vitorguimaraes9101 3 года назад

    Great video, thanks for sharing! It helped me a lot!!

  • @bendanielspercussion
    @bendanielspercussion 2 года назад

    I love you, Dan! You're the best!

  • @hyp3ri0nn
    @hyp3ri0nn 4 года назад

    This was the best video about reduce method ever

  • @md.abdullahalmasum4942
    @md.abdullahalmasum4942 2 года назад +1

    this is the best technique for teaching students.

  • @huetemaier2499
    @huetemaier2499 5 лет назад

    Thank you, I understood everything.

  • @MrWardo2009
    @MrWardo2009 2 года назад +1

    Thanks for making this video!

  • @IvanTomljenovic
    @IvanTomljenovic 6 лет назад

    I find your tutorials the easiest to follow while learning Js.
    You should definitely start a podcast!

  • @Dr_Ali.Aljboury
    @Dr_Ali.Aljboury 5 лет назад

    Wow you amazing man and your explanation have many ways to give idea for one time. I do appreciate your video I will watching all your video from now because my work depends on this videos....😘❤😘

  • @miguelbarrera4449
    @miguelbarrera4449 3 года назад

    Estuvo asombroso y logré comprenderlo 10/10

  • @icysnake1989
    @icysnake1989 3 года назад +1

    Thanks for help understand reduce() function

  • @genovo
    @genovo 3 года назад

    trying to wrap my head around following when i saw your video, thanks it helped:
    const pipeline = (...fns) =>
    (value) =>
    fns.reduce((acc, fn) => fn(acc), value)
    const celsiusMult = (number) => number * 9/5
    const celsiusAdd = (number) => number + 32
    const fahrenheit = pipeline(celsiusMult, celsiusAdd)
    fahrenheit(100)
    // 212

  • @salinajohn370
    @salinajohn370 3 года назад

    I just LOOVE his introduction😆

  • @alexander5052
    @alexander5052 Год назад

    finally it makes sense! Thank you so much!!!!

  • @XpLoeRe
    @XpLoeRe 2 года назад +1

    .Reduce() gives you the ability to iterate over the array while keeping track of current index and previous index.
    thank you!

  • @thesmartest1919
    @thesmartest1919 3 года назад

    thank you so much , u made it so easy to understand

  • @collinkreutzer8414
    @collinkreutzer8414 6 лет назад +5

    Reminds me of the c++ stl library algorithms using lambda expressions. Really nice way to write compact and fast code. Great to see it coming to JS as well.

    • @rolfnoduk
      @rolfnoduk 6 лет назад

      Collin Kreutzer it's not new fyi

    • @mathematicalmatt
      @mathematicalmatt 6 лет назад

      You got that backwards. C++ was one of the last languages to use functional ideas.

    • @seancpp
      @seancpp 4 года назад

      Matthew Hoiland
      C++11 released lambdas.
      ES2015 released arrow functions
      You’re wrong pal

  • @InayetHadi
    @InayetHadi 5 лет назад

    Excellent explanation!

  • @ddprasad9952
    @ddprasad9952 3 года назад

    You're an amazing teacher 👏😃😃

  • @carlosjunod5424
    @carlosjunod5424 4 года назад

    fist video of this channel I've ever seen (already subscribed)... for a brief moment I thought it was jeff Goldblum teaching coding! lol.. awesome video, I love the energy

  • @sergeikupchyk5349
    @sergeikupchyk5349 3 года назад

    You are the man. Thanks for your video

  • @danielbenisti3664
    @danielbenisti3664 5 лет назад

    the best video of reduce method!

  • @jacquelingonza9685
    @jacquelingonza9685 3 года назад +1

    I was close to give up finally light at the end of the tunnel. Thank you

  • @anthonythompson3806
    @anthonythompson3806 2 года назад

    The .reduce() method has never been this entertaining!

  • @briancook6875
    @briancook6875 3 года назад

    this helped me a lot. thanks!

  • @maheshjamdade1
    @maheshjamdade1 5 лет назад +2

    best part of the video at 6:15 the way you broke the function

  • @GregWarner1
    @GregWarner1 5 лет назад

    Super helpful, thank you!

  • @PabloMartinezfr
    @PabloMartinezfr 5 лет назад

    You are amazing Teacher!!!!

  • @Person-hb3dv
    @Person-hb3dv 2 года назад

    you are a great teacher sir

  • @theuseraccountname
    @theuseraccountname 2 года назад +1

    I played around a bit and this is what I made:
    _array.reduce((acc, val) => Math.min(acc, val))
    _array.reduce((acc, val) => Math.max(acc, val))

  • @ebonitasha
    @ebonitasha 2 года назад

    they way he teach, have me excited as well

  • @aaronargottelopez3488
    @aaronargottelopez3488 4 года назад

    I am thankful to you. Thanks!

  • @marielacordeiro
    @marielacordeiro 3 года назад

    you have the best videos ever I love you thank you

  • @christianjt7018
    @christianjt7018 5 лет назад

    very good explanation, thanks

  • @jemjem8902
    @jemjem8902 4 года назад

    Thank you for this, I understand it now

  • @musa6173
    @musa6173 Год назад

    what are you?!?!?!
    some kinda magician?! that was so damn good. you explained it so well, man. thanks.

  • @Wastefuldragon
    @Wastefuldragon 4 года назад

    Best coding teacher ever

  • @OftFilms
    @OftFilms 6 лет назад

    Thank you,my code looks now better and cleaner

  • @haciendadad
    @haciendadad 5 лет назад

    I was trying to see the difference between your reducer example and just using a map function, but I guess that is where the accumulator comes in. The accumulator persist over all the iterations where in a map function, you would have to create a variable outside the function and in each iteration of the map function you could do math on that variable and change it accordingly but the reducer function provides that extra variable and allows you to use on each iteration. Nice. Thanks!!

  • @TimGn
    @TimGn 6 лет назад

    You are the living end. I love your instruction, it's great. #bestofyoutube

  • @cagrioz9798
    @cagrioz9798 5 лет назад

    Thank you for this video that was so usefull.

  • @user-xi9ig6it4v
    @user-xi9ig6it4v 6 лет назад +1

    Очень круто!!! Спасибо!

  • @avfoxstudios3226
    @avfoxstudios3226 2 года назад

    well explained....bravo

  • @MichaelMcCrae
    @MichaelMcCrae 3 года назад +6

    "I could probably use this thing called a ternary operator if I was a crazy person."

  • @akeronallkushi8074
    @akeronallkushi8074 3 года назад

    I just love you man!!