-
-
Save IrhaAli/eee94fa2114a4749d4ab2c295c8bf53d to your computer and use it in GitHub Desktop.
Returns multiplication tables from 1 to the maxValue.
This file contains 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
//helper function | |
const perMultiplicationTable = function(value, limit){ | |
let table = ''; | |
for (let i = 1; i <= limit; i++){ | |
table += `${i*value} `; | |
} | |
return table; | |
} | |
//main function | |
const multiplicationTable = function(maxValue) { | |
let tables = ''; | |
for (let i = 1; i <= maxValue; i++){ | |
tables += `${perMultiplicationTable(i, maxValue)}\n`; | |
} | |
return tables; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment