javascript - How to use mapping to transfer things to an empty array? -
i trying pass on function inside of variable inputone empty array of transferhere
this not seem working. how can map inside of inputone transferhere, transferred over?
var transferhere = []; var inputone = transferhere.map(function(name) { return (5 * name) - 20; });
the map
function iterates on array of values , generates new array of values.
for example:
var arr1 = [1,2,3]; var result = arr1.map(function(val){ return val + 1; }); //result be: [2,3,4]
so seems doing wrong , code should (assuming inputone array):
var transferhere= inputone.map(function(name) { return (5 * name) - 20; });
update:
from comment understand inputone function , want put it's actual content (i.e. string) in array, here how:
var arr1 = []; arr1.push(inputone.tostring());
Comments
Post a Comment