JSFiddle - React, Tailwind, and code Playground

by Jessie Lau

JavaScript

function countBy(x, n) {
  var z = [];
    for(var i = 1; i <= n; i++){
        z.push(i*x);
    }

  return z;
}

console.log(countBy(1, 5)); //[1,2,3,4,5]
console.log(countBy(2, 5)); //[2,4,6,8,10]