Advertisement
Didart

Numbers, Divisible by 9

Apr 5th, 2022
1,046
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function numbersDivisibleBy9(input) {
  2. let start = Number(input[0]);
  3. let end = Number(input[1]);
  4.  
  5. let sum = 0;
  6. let printNum = "";
  7. for (let index = start; index <= end; index++) {
  8.  
  9.     if (index % 9 === 0) {
  10.         sum += index;
  11.         printNum += `${index}\n`;
  12.     }  
  13. }
  14.  
  15. console.log(`The sum: ${sum}`);
  16. console.log(printNum);
  17.    
  18. }
  19. numbersDivisibleBy9(["100", "200"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement