DEV Community

loading...

Discussion on: Functional Programming.

Collapse
chety profile image
Chety

Good post, but few things to mention

  • Map does not modify/mutate array, instead it returns a brand new array.

  • Reduce does not have a default value as 0. If you do not specify anything for second parameter, it will take caller array's first item as initial value[That's why it is recommended to specify a initial value ].

  • In your find example variable name is a kind of misleading.

const index = countries.find((country) => country.includes('o')) ; //wrong
const country = countries.find((country) => country.includes('o')) ; //right
  • There is a typo in some definition. You said if all elements satisfy criteria, then it returns true, otherwise it returns false.

By the way thanks for your efforts to make 30DaysOfJs for community, Kudos :)