-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolutions.js
More file actions
93 lines (79 loc) · 1.47 KB
/
solutions.js
File metadata and controls
93 lines (79 loc) · 1.47 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
// use strict
function isNum(x){
return !isNaN(parseFloat(x))
}
function isBool (x){
return (typeof x === "boolean");
}
function isString(x){
return typeof x === 'string';
}
function isNeg(x){
return isNum(x) && (x < 0);
}
function lowerCase(a){
if(isString(a)){
return a.toLowerCase();
}
return false;
}
function isAllLowerCase(a){
if (isString(a)){
return a.toLowerCase()=== a;
}
return false;
}
function isAllUpperCase(a){
if (isString(a)){
return a.toUpperCase() === a;
}
return false;
}
function isNotPalindrome(a) {
let arr = [];
if (isString(a)){
arr = a.split('');
arr.reverse();
arr = arr.join('');
return (arr.toUpperCase() !== a.toUpperCase())
}
return true;
}
function multiplyBy2(a){
if (isNum(a)){
return a*2;
}
return false;
}
function convertHourToSec(a){
if (isNum(a) && !isNeg(a)){
return a*60*60;
}
return false;
}
function getLowestNumber(a, b, c){
if (isNum(a) && isNum(b) && isNum(c)){
return Math.min(a, b, c);
}
return false;
}
function addStringLengths(a, b){
if (isString(a) && isString(b)){
return a.length + b.length;
}
return false;
}
function subtract(a, b){
if (isNum(a) && isNum(b)){
return a-b;
}
return false;
}
function calculateChange(t, c){
if (isNum(t) && isNum(c)){
t = parseFloat(t);
c = parseFloat(c);
return `$${parseFloat(t-c)}`;
}
return false;
}