Skip to content

calling arrays of functions

sergio edited this page Nov 9, 2020 · 1 revision
let actionApplyer = function(start, ray) {
  let a = start

  for (let i = 0; i < ray.length; i++ ){
    a = ray[i](a)
  }

  return a
}

arrayOfTransforms = [
  function(a){ return a * 2 },
  function(a){ return a + 1000},
  function(a){ return a % 7 }
]

actionApplyer(13, arrayOfTransforms)

Clone this wiki locally