TZinovieva

Numbers, Divisible by 9 100/100

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