forked from jsd20191008/functions-practice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpset-functions.js
172 lines (97 loc) · 4.61 KB
/
pset-functions.js
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/***********
Problem: Triangles
Determine if a triangle is equilateral, isosceles, or scalene.
An equilateral triangle has all three sides the same length.
An isosceles triangle has at least two sides the same length. (It is sometimes specified as having exactly two sides the same length, but for the purposes of this exercise we'll say at least two.)
A scalene triangle has all sides of different length
Create a function named `typeOfTriangle()` that accepts three (3) parameters s1, s2 and s3. The function will return
"equilateral" if the three (3) sides are the same
"isosceles" if two (2) sides are the same
"scalene" if all three (3) sides are different
"not a triangle" if any of the sides are <= 0
Feel free to add any additional functions or variables you deem necessary to meet the above requirements
Test Cases:
Use the following test cases to confirm your program meets the success criteria
1. typeOfTriangle(4, 4, 4)
Expected Result: "equilateral"
2. typeOfTriangle(0, 4, 7)
Expected Result: "not a triangle"
3. typeOfTriangle(9, 8, 9)
Expected Result: "isosceles"
4. typeOfTriangle(12, 8, 7)
Expected Result: "scalene"
************/
console.log('Problem 1:')
// Add your code below this line
// Add your code above this line
/** added for formatting purposes **/
console.log('')
console.log('-----------------')
/***********
Problem: Phone Number Cleaner
Your task is to clean up differently formatted telephone numbers by removing punctuation and the country code (1) if present.
Create a function that accepts a formatted "phoneNumber" and removes all punctuation and an leading (1) if present
Feel free to add any additional functions or variables you deem necessary to meet the above requirements
Test Cases:
Use the following test cases to confirm your program meets the success criteria
1. phoneNumberCleaner("+1 (613)-995-0253")
Expected Result: 6139950253
2. phoneNumberCleaner("613-995-0253")
Expected Result: 6139950253
3. phoneNumberCleaner("1 613 995 0253")
Expected Result: 6139950253
4. phoneNumberCleaner("613.995.0253")
Expected Result: 6139950253
************/
console.log('Problem 2:')
// Add your code below this line
// Add your code above this line
/** added for formatting purposes **/
console.log('')
console.log('-----------------')
/***********
Problem: Wordy Math
Parse and evaluate simple math word problems returning the answer as an integer.
Create a function that accepts a "mathProblem" as a parameter and translate that word problem into an integer based math problems and returns an integer representing the answer
Feel free to add any additional functions or variables you deem necessary to meet the above requirements
Test Cases:
Use the following test cases to confirm your program meets the success criteria
1. wordyMath("What is 5 plus 13?")
Expected Result: 18
2. wordyMath("What is 7 minus 5?")
Expected Result: 2
3. wordyMath("What is 6 multiplied by 4?")
Expected Result: 24
4. wordyMath("What is 25 divided by 5?")
Expected Result: 24
************/
console.log('Problem 3:')
// Add your code below this line
// Add your code above this line
/** added for formatting purposes **/
console.log('')
console.log('-----------------')
/***********
Tags: functions
Problem: Nucleotide Count
The genetic language of every living thing on the planet is DNA. DNA is a large molecule that is built from an extremely long sequence of individual elements called nucleotides. 4 types exist in DNA and these differ only slightly and can be represented as the following symbols: 'A' for adenine, 'C' for cytosine, 'G' for guanine, and 'T' thymine.
Given a single stranded DNA string, compute how many times each nucleotide occurs in the string.
Create a function that accepts "dna" (string) and calculates how many times each nucleotide occurs in the string
Feel free to add any additional functions or variables you deem necessary to meet the above requirements
Test Cases:
Use the following test cases to confirm your program meets the success criteria
1. nucleotideCount("GGGGGTAACCCGG")
Expected Result: { 'A': 2, 'T': 1, 'C': 3, 'G': 7 }
2. nucleotideCount("'GGGGGGGG'")
Expected Result: { 'A': 0, 'T': 0, 'C': 0, 'G': 8 }
3. nucleotideCount("CGATTGGG")
Expected Result: { 'A': 1, 'T': 2, 'C': 1, 'G': 4 }
4. nucleotideCount("AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC")
Expected Result: { 'A': 20, 'T': 21, 'C': 17, 'G': 12 }
************/
console.log('Problem 4:')
// Add your code below this line
// Add your code above this line
/** added for formatting purposes **/
console.log('')
console.log('-----------------')