-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanswer.js
More file actions
55 lines (43 loc) · 1.23 KB
/
Copy pathanswer.js
File metadata and controls
55 lines (43 loc) · 1.23 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
//question 1:
function describeValue(value) {
return `${typeof value} | ${value ? "truthy" : "falsy"}`;
}
// question 2:
function getDayType(day){
switch(day.toLowerCase()){
case "friday":
return "Weekend";
case "saturday":
return "Weekend";
case "sunday":
return "Working Day";
case "monday":
return "Working Day";
case "tuesday":
return "Working Day";
case "wednesday":
return "Working Day";
case "thursday":
return "Working Day";
default:
return "Invalid Day";
}
}
//question 3:
function validateUsername(username){
if (username.length < 4) return "Too Short";
if (username.includes(" ") === true) return "No Space Allowed";
if (username.toLowerCase().includes("admin")) return "Reserved Word";
return "Available";
}
// question 4:
function getCngFare(distance, isNight = false, waitingMinutes = 0){
let totalFare = 0;
if (distance > 2){
totalFare = 50 + (distance - 2) * 15;
}
else{totalFare = 50;}
if (isNight === true) totalFare *= 1.2;
if (waitingMinutes > 0) totalFare += waitingMinutes * 2;
return totalFare;
}