Skip to content

Instantly share code, notes, and snippets.

@IrhaAli
Created October 7, 2022 21:01
Show Gist options
  • Save IrhaAli/eee94fa2114a4749d4ab2c295c8bf53d to your computer and use it in GitHub Desktop.
Save IrhaAli/eee94fa2114a4749d4ab2c295c8bf53d to your computer and use it in GitHub Desktop.
Returns multiplication tables from 1 to the maxValue.
//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