Question:

Write the $$$.map() function so the result variable is assigned to the array [4, 8, 12].

result = $$$.map([2, 4, 6], function(num) {
  return num * 2;
});
console.log(result);

Answer:

$$$ = {
  map: function(arr, callback) {
    result = [];
    arr.forEach(function (e) {
      result.push(callback(e));
    });
    return result;
  }
}

Keywords:

© 2017 QuizBucket.org