I'm trying to use ES6 arrow function with .filter to return adults (Jack & Jill). It appears I cannot use an if statement.   What do I need to know in order to do this in ES6?  var family = [{"name":"Jack",  "age": 26}...
I'm in the process of learning functional programming, and completely getting rid of for loops has been a challenge sometimes, because they provide so much control and freedom. Below is an example of checking if a string is an isogram or not (no...
I'm trying to concat an array of arrays using reduce and I figured that I could use the Array.prototype.concat function like this:  arr = [[1],[2],[3]] arr.reduce((a, b) => Array.prototype.concat(a, b), [])   Which works fine and gives me the...
I'm having an issue when using higher-order functions. Let's say I have the following code that doesn't use them (instead call global functions):  import {db_insert} from 'some-db-lib' // function with side-effect  const save_item...
Everyone nowadays tries to use these kind of higher-order functions to get promising result with writing less code. But I wonder how these functions works internally.  Suppose if I write something like    var numbers = [16, 25, 36]; var results = num...
I was reading through Eloquent JavaScript, when I came across this in chapter 5. :     you can have functions that create new functions.  function greaterThan(n) {   return function(m) { return m > n; }; } var greaterThan10 = greaterThan(10);...
can someone explain to me what is going on in the following code. The function is receiving n as parameter, so where is the m coming from? The whole code is confusing.. if someone can explain?    function greaterThan(n) {   return function(m) { retur...
I'm just learning how to use JS higher-order functions (map, forEach, reduce, etc), and have stumbled into confusion.  I'm trying to write a simple 'range' function, but can't seem to populate my output array.  This is the goal:...
I have a function that divides two input arguments:   const divide = (x, y) => {     return x / y;   };   I have a second function that takes the divide function as its input argument and returns a new function.    function test(func) {      retur...
I'm learning to code and I'm trying to understand Higher Order Functions and abstractions.  I don't understand how this piece of code runs to return "true".  function greaterThan(n) {   return function(m) { return m > n; }; }...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.