7 kyu
Easy mathematical callback
6,508 of 7,394nghier
Description:
Task
Write the processArray function, which takes an array and a callback function as parameters. The callback function can be, for example, a mathematical function that will be applied on each element of this array. Optionally, also write tests similar to the examples below.
Examples
Array
[4, 8, 2, 7, 5]
after processing with functionvar myArray = [4, 8, 2, 7, 5]; myArray = processArray(myArray,function (a) { return a * 2; });
will be
[ 8, 16, 4, 14, 10 ]
.Array
[7, 8, 9, 1, 2]
after processing with functionvar myArray = [7, 8, 9, 1, 2]; myArray = processArray(myArray, function (a) { return a + 5; });
will be
[ 12, 13, 14, 6, 7 ]
.
Algorithms
Similar Kata:
Stats:
Created | Jan 15, 2015 |
Published | Jan 15, 2015 |
Warriors Trained | 10361 |
Total Skips | 354 |
Total Code Submissions | 23768 |
Total Times Completed | 7394 |
JavaScript Completions | 6508 |
Python Completions | 866 |
C# Completions | 126 |
Total Stars | 55 |
% of votes with a positive feedback rating | 84% of 585 |
Total "Very Satisfied" Votes | 450 |
Total "Somewhat Satisfied" Votes | 84 |
Total "Not Satisfied" Votes | 51 |