Guest User

Untitled

a guest
Jan 19th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. var arr= ["three", "2", "five", "ten", "111", 1, 2, "forty", "33", 33];
  2.  
  3. var strArr = ["three", "2", "five", "ten", "111","forty", "33"];
  4. var numArr = [1, 2, 33];
  5.  
  6. ['number', 'string'].map(i => arr.filter(a => typeof a == i));
  7.  
  8. var arr= ["three", "2", "five", "ten", "111", 1, 2, "forty", "33", 33];
  9.  
  10. var strArr = [];
  11. var numArr = [];
  12.  
  13. var arrayLength = arr.length();
  14. // iterates trough the array
  15. for (i; i < arr.length(); i++)
  16. {
  17. //Check if the given value in the array is string
  18. if (typeof arr[i] === 'string')
  19. {
  20. // adds the value you are checking to the strArr
  21. strArr.push(arr[i]);
  22. }
  23.  
  24. //Check if the given value in the array is integer
  25. if (typeof arr[i] === 'number' && isFinite(value))
  26. {
  27. // adds the value you are checking to the numArr
  28. numArr.push(arr[i]);
  29. }
  30. }
  31.  
  32. var arr= ["three", "2", "five", "ten", "111", 1, 2, "forty", "33", 33];
  33. var num=[];
  34. var str=[];
  35. for(i=0;i<arr.length;i++){
  36. if(arr[i].includes(") || arr[i].includes('))
  37. str.push(arr[i]);
  38. else
  39. num.push(arr[i]);
  40. }
Add Comment
Please, Sign In to add comment