Created
August 8, 2020 23:48
-
-
Save cplpearce/8233028761ba17ef5e559aff7d6fa334 to your computer and use it in GitHub Desktop.
Kata 8 - Multiplication Table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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