-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprototype.js
More file actions
52 lines (50 loc) · 990 Bytes
/
prototype.js
File metadata and controls
52 lines (50 loc) · 990 Bytes
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
function calculator(string) {
let arr = string.split(' ');
let res;
switch (arr[1]) {
case '+':
res = +arr[0] + +arr[2];
break;
case '-':
res = +arr[0] - +arr[2];
break;
case '*':
res = +arr[0] * +arr[2];
break;
case '/':
res = +arr[0] / +arr[2];
break;
}
return res;
}
var font_ar = [
1,
4,
5,
9,
10,
40,
50,
90,
100,
];
var font_rom = [
"I",
"IV",
"V",
"IX",
"X",
];
function to_arab(text) {
var text = text.toUpperCase();
var rezult = 0;
var posit = 0;
var n = font_ar.length - 1;
while (n >= 0 && posit < text.length) {
if (text.substr(posit, font_rom[n].length) == font_rom[n]) {
rezult += font_ar[n];
posit += font_rom[n].length;
} else n--;
}
return rezult;
}