Explore BrainMass

Javascript Array Functions

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

Using Javascript: Write a function called applyFunction that receives an array (arr) and a function (func) as a parameter. The applyFunction code should then repeatedly call the parameter function on each element in the array, storing the result back into the array at the same point. See the example below for how the call to applyFunction should work:

Please refer to the attached document for full details.

© BrainMass Inc. brainmass.com October 25, 2018, 7:03 am ad1c9bdddf


Solution Summary

This solution contains jscript code for two functions - one that calls another function passed as parameter to perform operation on each element of the array, and another to add two arrays.

See Also This Related BrainMass Solution

Create a JavaScript function "merge" that take two sorted arrays as parameters and merges them into one sorted array.

I'm trying to write a function merge that take two sorted arrays as parameters. The function should create a new array whose size is the sum of the two parameter array lengths. The merge function should then fill in the new array with elements from the two parameters such that the two sorted arrays are merged into one sorted array.

I'm creating the function in JavaScript and calling it in a HTML file.

View Full Posting Details