Mary U
03-20-2009, 03:13 AM
I am attempting to do some basic array work.
Here I am accepting an array, and a value of a variable to perform multiplication against my array, then write the product back into the array.
However this never seems to resolve, I never get an alert box with my result.
Can someone tell me where I have gone astray?
function applyfunction(array, value){
var arr1 = [];
for (var i = 0; i < array.length; ++i) {
var elm = array[i];
elm = elm * value;
arr1[i] = elm;
}
return arr1;
}
var arr1 = [1,2,3];
var ans = applyfunction(arr1,5);
alert(ans);
I appreciate any help, I've been fiddling with this for a week and just want to get some output!
Mary
Here I am accepting an array, and a value of a variable to perform multiplication against my array, then write the product back into the array.
However this never seems to resolve, I never get an alert box with my result.
Can someone tell me where I have gone astray?
function applyfunction(array, value){
var arr1 = [];
for (var i = 0; i < array.length; ++i) {
var elm = array[i];
elm = elm * value;
arr1[i] = elm;
}
return arr1;
}
var arr1 = [1,2,3];
var ans = applyfunction(arr1,5);
alert(ans);
I appreciate any help, I've been fiddling with this for a week and just want to get some output!
Mary