Skip to content

Instantly share code, notes, and snippets.

@cplpearce
Created August 8, 2020 23:48
Show Gist options
  • Save cplpearce/8233028761ba17ef5e559aff7d6fa334 to your computer and use it in GitHub Desktop.
Save cplpearce/8233028761ba17ef5e559aff7d6fa334 to your computer and use it in GitHub Desktop.
Kata 8 - Multiplication Table
const multiplicationTable = function(maxValue) {
let numArray = [];
for (i = 1; i <= maxValue; i++) {
let rowArray = [];
for (j = 1; j <= maxValue; j++) {
rowArray.push(i * j);
}
numArray.push(rowArray);
}
let returnString = '';
for (let ar of numArray) {
returnString += ar.join(' ') + '\n';
}
return returnString;
};
console.log(multiplicationTable(1));
console.log(multiplicationTable(5));
console.log(multiplicationTable(10));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment