5 Real Life Examples of Array Reduce in JavaScript

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 ก.ค. 2024
  • A lot of guides online (including my own) will show the "sum of all numbers" example when explaining how the array reduce method works.
    In this video, I'll take you through 5 unique and applicable examples of using the reduce method in JavaScript.
    Chapters:
    0:00 Intro
    0:40 Find the Sum of Numbers
    3:01 Find the Sum of Numbers in an Object
    4:49 Convert a 2D Array into an Object
    7:31 Find the Max Value of an Array of Objects
    9:47 Find the Number of Occurrences of Each Element
    12:21 Outro
    THE ULTIMATE JAVASCRIPT DOM CRASH COURSE 👇
    www.udemy.com/course/the-ulti...
    For your reference, check this out:
    developer.mozilla.org/en-US/d...
    🏫 My Udemy Courses - www.udemy.com/user/domenic-co...
    🎨 Download my VS Code theme - marketplace.visualstudio.com/...
    💜 Join my Discord Server - / discord
    🐦 Find me on Twitter - / dcodeyt
    💸 Support me on Patreon - / dcode
    📰 Follow me on DEV Community - dev.to/dcodeyt
    📹 Join this channel to get access to perks - / @dcode-software
    If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!
    #dcode #javascript

ความคิดเห็น • 30

  • @dcode-software
    @dcode-software  ปีที่แล้ว +4

    *FULL VIDEO ON ARRAY REDUCE:*
    th-cam.com/video/3mGbzELRBkM/w-d-xo.html
    *Enrol Now - THE ULTIMATE JAVASCRIPT DOM CRASH COURSE* 👇
    www.udemy.com/course/the-ultimate-javascript-dom-crash-course/?referralCode=DC343E5C8ED163F337E1

  • @user-shamrai
    @user-shamrai ปีที่แล้ว +1

    You have a gift for explaining things clearly. I don't even understand English very well, but I understood you completely. Thank you

  • @user-hb7sl4hh1y
    @user-hb7sl4hh1y 11 หลายเดือนก่อน

    dude! killer video. You're right, most reduce method tutorials focus on one scenario, adding up all the element of an array. Your video was far more comprehensive to real world scenarios. Very well explained too!

  • @dev_ression
    @dev_ression ปีที่แล้ว +3

    Good to meet a fellow Australian programmer bro! You've got a new sub

    • @dcode-software
      @dcode-software  ปีที่แล้ว +3

      Welcome 😊 thank you for subscribing. Good luck with your channel!

  • @saman6199
    @saman6199 ปีที่แล้ว

    I just found your channel, and as someone mentioned, good to see a nice Aussie instructor. Thanks 🙏

  • @nawal7721
    @nawal7721 ปีที่แล้ว +3

    how is prev[color] returning the color name but then (prev[color] || 0) + 1 is return a number. Also if I just console.log(prev[color]) it outputs numbers but i though I should output {green}. I'm well confused.

  • @parmjeetmishra2
    @parmjeetmishra2 9 หลายเดือนก่อน

    Amazing .. Thank you

  • @allhailalona
    @allhailalona หลายเดือนก่อน

    great vidoe! thank you very much!

  • @user-tk2mx9vl2h
    @user-tk2mx9vl2h ปีที่แล้ว

    I recommend this lecture. thanks a lot👍👍👍

  • @NedumEze
    @NedumEze ปีที่แล้ว

    Amazing. Thank you Dom.
    You've got a Computer's mind! Am envious. Wish you could help me figure out a PHP challenge.

  • @skolotoi4588
    @skolotoi4588 ปีที่แล้ว

    thanks, Dom!

  • @taofeeqomotolani2311
    @taofeeqomotolani2311 ปีที่แล้ว +1

    DOM, thanks man

  • @DavidMwai-dj8up
    @DavidMwai-dj8up ปีที่แล้ว

    Always a great tutor: Subscription should be @1m+ for the great content you always deliver

  • @marimuthur9456
    @marimuthur9456 ปีที่แล้ว

    You are really awesome bro thank you so much for your knowledge sharing keep go ahead 👌🏼👌🏼👌🏼😊😊

  • @julioarruda8182
    @julioarruda8182 ปีที่แล้ว

    thanks again

  • @neilgregsoil1989
    @neilgregsoil1989 ปีที่แล้ว

    GOOD SIR!

  • @AidaHashemii
    @AidaHashemii หลายเดือนก่อน

    perfect

  • @rysmo0
    @rysmo0 ปีที่แล้ว +1

    Nice one. Better used in complex methods.

  • @devax1t
    @devax1t ปีที่แล้ว

    i did learn something :)

  • @streamx2
    @streamx2 ปีที่แล้ว

    I'm a little confused with the house building example. Shouldn't it be return prev.cost + material.cost?

  • @karlstenator
    @karlstenator ปีที่แล้ว

    At 9:35 - if I try to return either the object, or the name of the highest salary object - I get an undefined return. Could you post the solution please?

  • @abubalo
    @abubalo ปีที่แล้ว +3

    Array.reduce() is like array.filter() but on steroid. You can do a lot with it.

  • @capslock3250
    @capslock3250 9 หลายเดือนก่อน

    7:17 return prev[key] = value ?

  • @suelingsusu1339
    @suelingsusu1339 ปีที่แล้ว

    👌👌👌👍👍👍👍🙏🙏🙏🙏🖖🖖🖖🖖🌹🌹🌹🌹

  • @ali_mov_f
    @ali_mov_f ปีที่แล้ว +1

    first

    • @jordanski5421
      @jordanski5421 ปีที่แล้ว

      same

    • @Leron_T
      @Leron_T ปีที่แล้ว

      @@jordanski5421 same

    • @squarerootof2
      @squarerootof2 ปีที่แล้ว

      Congrats. You'll all get a lame, dummy & cringe award to add to your collections.