Skip to content

Instantly share code, notes, and snippets.

@woowawebui
Created May 10, 2017 12:23
Show Gist options
  • Save woowawebui/721999d6ba6f127033c6fba574756cfe to your computer and use it in GitHub Desktop.
Save woowawebui/721999d6ba6f127033c6fba574756cfe to your computer and use it in GitHub Desktop.
구구단
for (var i = 1; i <= 9; i++) {
for (var j = 1; j <= 9; j++) {
console.log(i, 'X', j, '=', i * j);
}
}
eachDan(7);
for (var i = 8; i <= 18; i += 2) eachDan(i);
printDan([3, 7, 9, 13]);
rangeDan(1, 9);
var eachDan = function(n) {
for (var i = 1; i <= 9; i++) {
console.log(n, 'X', i, '=', n * i);
}
};
var printDan = function(dan) {
for (var i = 0; i < dan.lenght; i++) {
eachDan(dan[i]);
}
};
var rangeDan = function(min, max) {
var arr = [];
for (var i = min; i <= max; i++) arr.push(i);
printDan(arr);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment