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 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...
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:...
In the following function why does "i" argument increment?  function colWidths(rows) {       return rows[0].map(function(_, i) {         return rows.reduce(function(max, row) {           return Math.max(max, row[i].minWidth());         }, 0);...
I'm trying to use Javascript's higher-order functions for functional programming. However, they are producing unexpected results:  ['1','2','3','4'].map(parseInt) // [1, NaN, NaN, NaN]  ['1','2'...
I have been struggling for quite some time with the idea of sum types in Javascript. The language includes neither native sum types nor pattern matching. While you can mimic sum types with plain old Javascript Objects and the prototype system and int...
I'm trying to solve the problem below using reduce but I'm not able to get the correct count of even and odd numbers in the object.  Can someone please guide me what's wrong in my code?     Create a function countBy that accepts an array...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.