Created
May 10, 2017 12:23
-
-
Save woowawebui/721999d6ba6f127033c6fba574756cfe to your computer and use it in GitHub Desktop.
구구단
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
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