Advertisement
DNNdrago

1. Number Checker

Jul 24th, 2014
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. function printNumbers(n) {
  2. var exist = false;
  3. var result = '';
  4. for (var i = 1; i <= n; i+=1) {
  5. if(i % 4 !== 0 && i % 5 !== 0) {
  6. exist = true;
  7. result += i + ', ';
  8. }
  9. }
  10.  
  11. return exist ? result : 'no';
  12. }
  13.  
  14.  
  15.  
  16. console.log(printNumbers(20));
  17. console.log(printNumbers(-5));
  18. console.log(printNumbers(13));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement