-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
43 lines (33 loc) · 1.04 KB
/
index.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
function fahrenheitToCelsius(degreesFahrenheit) {
// The equation to convert from fahrenheit to celsius is
// (<degrees in fahrenheit> - 32) * 5/9 = <degrees in celsius>
let degreesCelsius;
(degreesFahrenheit - 32) * 5/9;
return degreesFahrenheit;
}
function celsiusToFahrenheit(degreesCelsius) {
// The equation to convert from celsius to fahrenheit is
// (<degrees in celsius> * 9/5) + 32 = <degrees in fahrenheit>
let degreesFahrenheit = (degreesCelsius * 9/5) + 32;
return degreesFarenheit;
}
function getFirstStringFromArray(list) {
// if list doesn't have a length property or it is 0 then it either isn't an array or
// it is an empty array. In either case, return null.
if (!list.length) {
return null;
}
let index = 0;
while(index < list.length) {
if (typeof list[index] === 'string') {
return list[index];
}
index++;
}
return null;
}
module.exports = {
fahrenheitToCelsius,
celsiusToFahrenheit,
getFirstStringFromArray
}