The source of the topic
Leetcode topic, website: 2635. Convert each element in the array - LeetCode
Problem-solving ideas:
Simulate as required.
Problem-solving code:
/**
* @param {number[]} arr
* @param {Function} fn
* @return {number[]}
*/
var map = function(arr, fn) {
var returnedArray=new Array();
for(var i=0;i<arr.length;i++){
returnedArray[i]=fn(arr[i],i);
}
return returnedArray;
};
Summarize:
No official solution.