Skip to content

moetezch/wta

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WTA

RSS feed parser

Getting Started

Prerequisites

yarn

Develop

yarn start

Array methods

Array map

Array.prototype.mapClone = function (fn) {
  const newArray = []
  for (let i = 0; i < this.length; i++) {
    newArray.push(fn(this[i]))
  }
  return newArray
}

Array filter

Array.prototype.filterClone = function (fn) {
  const newArray = []
  for (let i = 0; i < this.length; i++) {
    if (fn(this[i])) {
      newArray.push(this[i])
    }
  }
  return newArray
}

Array reduce

Array.prototype.reduceClone = function (fn, initialValue) {
  if (initialValue) {
    let sum = initialValue
    for (let i = 0; i < this.length; i++) {
      sum = fn(sum, this[i])
    }
    return sum
  } else {
    let sum = this[0]
    for (let i = 1; i < this.length; i++) {
      sum = fn(sum, this[i])
    }
    return sum
  }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published