Професионална програма
Loading...
+ Нов въпрос
Koulinsky avatar Koulinsky 0 Точки

Divisible by 9 problem

Hello and good day folks.

I'm stuck on task 8 - Divisible by 9 from JS basic.

I cannot seem to find a solution how to print the numbers separated with space.

Any help will be welcomed.

Here's my code: 

 

function divisible(input, inputB) {

  first = Number(input);

  second = Number(inputB);

  let sum = 0;

  let output = '';

  for (let i = first; i < second; i++) {

    if (i % 9 === 0) {

      sum += i;

      output += i;

    }

  }

 

  console.log(`${sum}`);

  console.log(`${output}`);

}

Тагове:
0
Programming Basics
Axiomatik avatar Axiomatik 540 Точки
function solve(min, max) {
    min = Number(min);
    max = Number(max);
    let sum = 0;
    let output = "";
    for (let i = min; i <= max; i++) {
        if (i % 9 === 0) {
            sum += i;
            output += i + " ";
        }
    }
    console.log(sum);
    console.log(output);
}

Best,

0