forked from gabischool/Week4_JS_Functions_Assignment
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchallenges.js
More file actions
137 lines (87 loc) Β· 3.76 KB
/
challenges.js
File metadata and controls
137 lines (87 loc) Β· 3.76 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
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
/*
Task 1: Library Late Fee Calculator ππππ
You are working at a library and need to calculate late
fees for overdue books. Write a function called `calculateLateFee`
that takes the number of overdue days as input and calculates
the fee ($0.25 per day). Prompt the user to input the
number of overdue days.
Log the result as:
"The late fee is $[amount]."
Example:
User Input: 10
Output: "The late fee is $2.50."
*/
// βοΈ βοΈ βοΈ βοΈ Write the function here βοΈ βοΈ βοΈ βοΈ
// Extra Task:
// - Convert the function into a function expression.
/*
Task 2 : Favorite Color Finder ππππ
You are designing a game that asks players for their favorite color.
Write a function called `findColorMeaning` that takes a color as input
(prompt the user) and logs the following meanings:
- "Blue: You love calm and peace."
- "Red: You are passionate and bold."
- "Green: You are connected to nature."
- "Yellow: You radiate happiness and energy."
- For any other color: "That's a unique choice!"
Example:
User Input: "Red"
Output: "Red: You are passionate and bold."
*/
// βοΈ βοΈ βοΈ βοΈ Write the function here βοΈ βοΈ βοΈ βοΈ
// Extra Task:
// - Rewrite the function using an arrow function.
/*
Task 3 : Lawyer's Case Log ππππ
Youβre a lawyer, and youβve been assigned to organize your case files.
Write a function called `logCase` that takes the client's name and
the case number as parameters. For each case, log:
"Case #[caseNumber]: [clientName]'s case is now logged."
Example:
Input: logCase("John Doe", 12345)
Output: "Case #12345: John Doe's case is now logged."
*/
// βοΈ βοΈ βοΈ βοΈ Write the function here βοΈ βοΈ βοΈ βοΈ
// Extra Task:
// - Rewrite the function as an arrow function.
/*
Task 4 : Attendance Tracker ππππ
Youβre a teacher tracking student attendance. Write a function called
`markAttendance` that takes a studentβs name and a boolean `isPresent`
value. If the student is present, log:
"[studentName] is present."
If the student is absent, log:
"[studentName] is absent."
Example:
Input: markAttendance("Amina", true)
Output: "Amina is present."
*/
// βοΈ βοΈ βοΈ βοΈ Write the function here βοΈ βοΈ βοΈ βοΈ
// Extra Task:
// - Convert the function into a function expression.
/*
STRETCH TASK: Student Grade Report Generator ππππ
You are a teacher, and you want to automate the creation of detailed grade reports for your class. Write a program that includes the following steps:
1. Write a function called `calculateAverage` that takes three test scores (numbers) as parameters and returns the average of those scores.
2. Write another function called `determineGrade` that takes the average score as a parameter and returns the letter grade based on the following rules:
- "A" for average scores of 90 and above
- "B" for scores between 80 and 89
- "C" for scores between 70 and 79
- "F" for scores below 70
3. Write a third function called `generateReport` that:
- Takes a student's name and three test scores as parameters.
- Uses `calculateAverage` to calculate the average score.
- Uses `determineGrade` to find the letter grade.
- Returns a full report string in this format:
"[StudentName] - Average Score: [average], Grade: [letterGrade]"
4. Finally, use the `prompt` function to input the studentβs name and three test scores, and display the generated report using `console.log`.
Example:
User Input:
Name: Amina
Scores: 85, 90, 78
Output:
"Amina - Average Score: 84.33, Grade: B"
Extra Credit:
- Extend the program to accept multiple students' names and scores and generate a report for each student using a loop.
- Use an arrow function for at least one of the functions.
*/