forked from AdamMomen/warmUp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwarmUp13.js
More file actions
111 lines (58 loc) · 2.43 KB
/
Copy pathwarmUp13.js
File metadata and controls
111 lines (58 loc) · 2.43 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
/* 1. Create a function that takes a Roman numeral as its argument and returns its value as a numeric decimal integer. You don't need to validate the form of the Roman numeral.
Modern Roman numerals are written by expressing each decimal digit of the number to be encoded separately, starting with the leftmost digit and skipping any 0s. So 1990 is rendered "MCMXC" (1000 = M, 900 = CM, 90 = XC) and 2008 is rendered "MMVIII" (2000 = MM, 8 = VIII). The Roman numeral for 1666, "MDCLXVI", uses each letter in descending order.
Example:
solution('XXI'); // should return 21
Help:
Symbol Value
{
I : 1,
V : 5,
X : 10,
L : 50,
C : 100,
D : 500,
M : 1,000
}
2. Complete the method/function so that it converts dash/underscore delimited words into camel casing. The first word within the output should be capitalized only if the original word was capitalized (known as Upper Camel Case, also often referred to as Pascal case).
Examples:
toCamelCase("the-stealth-warrior") // returns "theStealthWarrior"
toCamelCase("The_Stealth_Warrior") // returns "TheStealthWarrior"
3. In this kata you will create a function that takes a list of non-negative integers and strings and returns a new list with the strings filtered out.
Example
filter_list([1,2,'a','b']) == [1,2]
filter_list([1,'a','b',0,15]) == [1,0,15]
filter_list([1,2,'aasf','1','123',123]) == [1,2,123]
*/
// Q1: The following algorithim only adds (partial answer)
function deRomanize(str){
var arr = str.split('');
var acc = 0
var Decoder = {
I : 1,
V : 5,
X : 10,
L : 50,
C : 100,
D : 500,
M : 1000
}
for (var i = 0; i < arr.length; i++) {
for (var j = 0; j < Object.keys(Decoder).length ; j++) {
if (arr[i] === Object.keys(Decoder)[j]) {
acc = acc + Decoder[Object.keys(Decoder)[j]];
}
}
}
return acc;
}
//Q2:
function toCamelCase(str){
var arr= str.split("-")
var arr2=[]
for (var i = 0; i < arr.length; i++) {
if (i === 1)
arr2=arr.push(arr[i][0].toUpperCase())
}
return arr
}
//Q3: use parseIn()