Skip to content

Commit fdb8cd1

Browse files
Add a simple function digit_names().
It returns a string representing the name of the single digit that was passed to it.
0 parents  commit fdb8cd1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

digit_name.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
var digit_name = function () {
2+
var names = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'];
3+
4+
return function (n) {
5+
return names[n];
6+
}
7+
}();
8+
9+
alert(digit_name(3)); // 'three'

0 commit comments

Comments
 (0)