If I put 'let tableValue' outside a while loop then it shows the same number 10 times and when I write it inside the while loop then it prints a table of the value 'n'.
What is the difference between these two things?
function table(n) {
let i = 1;
let tableValue = (n * i);
while (i <= 10) {
console.log(tableValue);
i++;
}
}
table(9);
function table(n) {
let i = 1;
while (i <= 10) {
let tableValue = (n * i);
console.log(tableValue);
i++;
}
}
table(9);