Reduce Advanced - Part 4 of Functional Programming in JavaScript

Fun Fun Function · 244K views · 2015 · 13:23

Open on YouTube

Functional programmingWeb developmenttutorial

Why Stack Overflow recommends it

Stack Overflow users link it when explaining how JavaScript's reduce works or when asking about the chained map/split/trim code shown in the video.

Recommended by 1 people across 1 different months, 2017 to 2020.

What it is

Part 4 of Fun Fun Function's functional programming in JavaScript series, presented by Mattias Petter Johansson. It spends more time on reduce, building a hierarchical customer and orders structure from tab-delimited data using chained array methods.

What people said

Recommends James Garcia · 2019-01 · Stack Overflow · on “create JSON object starting from another JSON Object”

I think this would help let origin = { "Food": 900, "Shopping": 0, "Travel": 600, "Health": 0 }; let newObject = Object.entries(origin).reduce((obj, item) => { obj.push({ "label": item[0], "data": item[1] }); return obj; }, []) console.log(newObject) You can watch this video [this video] to have a better idea on how reduce works. Good luck!

Cites Anthony Gatlin · 2017-12 · Stack Overflow · on “How is JavaScript's Reduce assigning its value?”

Problem: I do not understand how reduce is assigning/reducing the customer name from the array. I need for someone to please explain precisely what is happening here. Detailed Description In episode 4 of Fun Fun Function 's functional programming series ( [this video] ), Mattias Petter Johansson walks through an example of loading in a simple data set for customers and their orders and transforming that data into hierarchical objects via the reduce function. Here is the sample tab-delimited data set--which I named locally as data.txt . mark johannson waffle iron 80 2 mark johannson blender 200 1 mark johannson knife 10 4 Nikita Smith waffle iron 80 1 Nikita Smith knife 10 2 Nikita Smith pot 20 3

Cites Niels · 2020-10 · Stack Overflow · on “multiple dot methods underneath eachother”

I would like to know something about a code fragment I saw. In the video he has a variable. And then he puts dot methods underneath each other that keeps manipulating that same beginning variable consecutively. It has spacing in front of it and then chains into lower lines all with . notation in front of it. The video where I saw it now is this one: [this video] At exactly the 6 minutes mark he has 3 of those dot methods underneath each other. Where can I find something about that? Cause I don't want to blindly copy the behavior. This is code from the video: import fs from 'fs' var output = fs.readFileSync('data.txt', 'utf8') .trim() .split('\n') .map(line => line.split('\t')) console.log('output