Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Understanding higher order JavaScript functions

function evenNumberFilter(number) {
  return number %2 == 0
}

function oddNumberFilter(number) {
  return !evenNumberFilter(number)
}

function evenNumberBeforeTen() {
  const result = []
  for(number=0; number<10; number++) {
    if (evenNumberFilter(number)) {
      result.push(number)
    }
  }
  return result
}

function oddNumberBeforeTen() {
  const result = []
  for(number=0; number<10; number++) {
    if (oddNumberFilter(number)) {
      result.push(number)
    }
  }
  return result
}

evenNumberBeforeTen();  //[0,2,4,6,8]
oddNumberBeforeTen();   //[1,3,5,7,9]
Source by www.google.com #
 
PREVIOUS NEXT
Tagged: #Understanding #higher #order #JavaScript #functions
ADD COMMENT
Topic
Name
5+7 =