jsartisan / frontend-challenges

FrontendChallenges is a collection of frontend interview questions and answers. It is designed to help you prepare for frontend interviews. It's free and open source.
https://frontend-challenges.com
20 stars 3 forks source link

78 - Array.prototype.map - javascript #81

Open jsartisan opened 2 weeks ago

jsartisan commented 2 weeks ago

index.js

export function arrayMap(array, callback) {
  const result = [];

  for (let i = 0; i < array.length; i++) {
    const current = array[i];

    result.push(callback(current, i, array))
  }

  return result;
}