Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. function runWithDebugger(callback, args) {
  2. debugger;
  3. if (Array.isArray(args)){
  4. callback(...args);
  5. }
  6. else {
  7. callback(args);
  8. }
  9. }
  10.  
  11. function sayHi() {
  12. console.log('Hi');
  13. }
  14. function sayHiTo(name) {
  15. console.log('hi ' + name);
  16. }
  17. function sayFullName(first, last) {
  18. console.log(first + ' ' + last);
  19. }
  20.  
  21. console.log('testing without any arguments');
  22. runWithDebugger(sayHi); // 'Hi'
  23. console.log('Testing sayHiTo with string input:');
  24. runWithDebugger(sayHiTo, 'gordon'); // 'Hi gordon'
  25. console.log('Testing sayHiTo Array one item:');
  26. runWithDebugger(sayHiTo, ['gordon']); // 'Hi gordon''
  27. console.log('Testing sayFullName Array multiple items:');
  28. runWithDebugger(sayFullName, ['gordon', 'zhu']); // 'gordon zhu'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement