Guest User

Untitled

a guest
Jan 23rd, 2018
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. function map (elemArray,funcion){
  2. var i=0;
  3.  
  4. if (map.arguments.length==2){
  5.  
  6. var arr = typeof(elemArray)=='object'&&(elemArray instanceof Array)?elemArray:[];
  7. if (arr.length>0){
  8. if (typeof(funcion)=='function'){
  9. var longitud = elemArray.length
  10. var resultado =[]
  11. for (;i<longitud;i++){
  12. resultado.push(funcion.call(this,elemArray[i]))
  13. }
  14. return resultado
  15. }else{
  16. return "el segundo parametro tiene que ser una funcion"
  17. }
  18.  
  19. }else{
  20. return "el primer parametro no es un array"
  21. }
  22.  
  23. }else{
  24. return "numero de argumentos no valido"
  25. }
  26.  
  27. }
Add Comment
Please, Sign In to add comment