Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function map (elemArray,funcion){
- var i=0;
- if (map.arguments.length==2){
- var arr = typeof(elemArray)=='object'&&(elemArray instanceof Array)?elemArray:[];
- if (arr.length>0){
- if (typeof(funcion)=='function'){
- var longitud = elemArray.length
- var resultado =[]
- for (;i<longitud;i++){
- resultado.push(funcion.call(this,elemArray[i]))
- }
- return resultado
- }else{
- return "el segundo parametro tiene que ser una funcion"
- }
- }else{
- return "el primer parametro no es un array"
- }
- }else{
- return "numero de argumentos no valido"
- }
- }
Add Comment
Please, Sign In to add comment