0

Sample Input:

3

Sample Output:

9 18 27

What i did :

var N = +userInput[0];
var b = [];

if (N === 0) {
  console.log('NULL');
} else {
for (i = 1; i <= N; i++ ) {
  b.push(i);
}

var c = b.map(b => b * 9);
console.log(c);

I get [9, 18, 27] as my output and I can't figure out how to change it to 9 18 27

Nick Parsons
  • 31,322
  • 6
  • 25
  • 44
krish
  • 1
  • 1

1 Answers1

0

You can just use join to transform the array into a string:

var N = 3;
var b = [];

if (N === 0) {
  console.log('NULL');
} else {
  for (i = 1; i <= N; i++ ) {
    b.push(i);
  }
}

var c = b.map(b => b * 9);
console.log(c.join(' '));
Greedo
  • 2,906
  • 1
  • 8
  • 22