-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnew.js
More file actions
126 lines (117 loc) · 2.46 KB
/
new.js
File metadata and controls
126 lines (117 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/* The input is the array arr given below. It is an array of numbers
The ouput has to be a string of the number in words.
Eg. 1234 will be One thousand two hundred and thirty four.
*/
const arr = [10563, 8524, 307, 52, 9, 0, 99902, 25091];
function main() {
for (var i = 0; i < arr.length; i++) {
var string = INR(arr[i]);
Logger.log(arr[i] + " - " + string);
}
}
function INR(input) {
var a, b, c, d, e, output, outputA, outputB, outputC, outputD, outputE;
var ones = [
"",
"one",
"two",
"three",
"four",
"five",
"six",
"seven",
"eight",
"nine",
];
if (input == "") {
output = "Null";
}
if (input === 0) {
// Zero
output = "Zero";
} else if (input === 1) {
// One
output = "One";
} else {
// More than one
// Tens
outputA = oneToHundred_(a);
// Hundreds
if (b > 0 && b < 10) {
outputB = ones[b];
console.log(outputB);
}
// Thousands
if (c > 10 && c < 100) {
outputC = oneToHundred_(c);
}
// Lakh
if (d > 100 && d < 1000) {
outputD = oneToHundred_(d);
}
// Crore
if (e > 1000 && e < 10000) {
outputE = oneToHundred_(e);
}
// Make string
output;
if (e > 0) {
outputE = outputE + " Lakh";
}
if (d > 0) {
outputD = outputD + " Thousand";
}
if (c > 0) {
outputC = outputC + " Hundred";
}
if (b > 0) {
outputB = outputB + " " + ones[b];
}
if (input > 100 && a > 0) {
}
if (a > 0) {
}
output = output + " only";
}
return output;
}
function oneToHundred_(num) {
var outNum;
var ones = [
"",
"one",
"two",
"three",
"four",
"five",
"six",
"seven",
"eight",
"nine",
];
var teens = [
"ten",
"eleven",
"twelve",
"thirteen",
"fourteen",
"fifteen",
"sixteen",
"seventeen",
"eighteen",
"nineteen",
];
var tens = [
"",
"",
"twenty",
"thirty",
"forty",
"fifty",
"sixty",
"seventy",
"eighty",
"ninety",
];
return outNum;
}