Advertisement
Guest User

Untitled

a guest
Jul 1st, 2017
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. function result(values) {
  2. let stringArr = [];
  3. let strCount = 0;
  4. let numberArr = [];
  5. let numCount = 0;
  6. let funcArr = [];
  7. let funcCount = 0;
  8. for (let i = 0; i <= arguments.length; i++) {
  9. if (typeof arguments[i] == 'string') {
  10.  
  11. stringArr.push(arguments[i])
  12.  
  13. strCount++;
  14. }
  15. else if (typeof arguments[i] == 'number') {
  16. numberArr.push(Number(arguments[i]));
  17. numCount++;
  18. }
  19. else if (typeof arguments[i] == 'function') {
  20. funcArr.push(arguments[i]);
  21. funcCount++;
  22. }
  23. }
  24. console.log('string: ' + stringArr.join(', '))
  25. console.log('number: ' + numberArr.join(', '))
  26. console.log('function: ' + funcArr.join(', '))
  27. console.log('string = ' + strCount)
  28. console.log('number = ' + numCount)
  29. console.log('function = ' + funcCount)
  30. }
  31. result('cat', 42, 'dog', function () { console.log('Hello world!') });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement