forked from gabischool/Week5_JS_Assignment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcallbacks.js
75 lines (51 loc) · 1.93 KB
/
callbacks.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
/*
Task 1: Simple Welcome Message 💌💌💌💌
You are building a simple messaging system. Write a function called `sendMessage` that:
1. Takes a user name and a callback function as arguments.
2. The callback function should log a welcome message.
Steps:
- Create the callback function to log: "Welcome, [name]!"
Example:
Input:
sendMessage("Amina", theCallBackFunction);
Expected Output:
- "Welcome, Amina!"
*/
// ✍️ Solve it here ✍️
/*
Task 2: Temperature Checker 🌡️🌡️🌡️🌡️
You are creating a temperature monitoring system. Write a function called `checkTemperature` that:
1. Takes a temperature value and a callback function as arguments.
2. The callback function should evaluate whether the temperature is "Hot", "Warm", or "Cold" based on the following:
- "Hot" if the temperature is above 30.
- "Warm" if the temperature is between 15°C and 30.
- "Cold" if the temperature is below 15.
Steps:
- Create the callback function to evaluate and log:
- "[temperature]°C is Hot/Warm/Cold."
Example:
Input:
checkTemperature(35, theCallBackFunction);
Expected Output:
- "35°C is Hot."
- "22°C is Warm."
- "10°C is Cold."
*/
// ✍️ Solve it here ✍️
/*
Task 3: Quiz Evaluator 📚📚📚📚
You are building a quiz system. Write a function called `evaluateAnswer` that:
1. Takes a question, a correct answer, and a callback function as arguments.
2. The callback function should compare the user's answer with the correct answer and log whether the answer is correct or not.
Steps:
- Create the callback function to evaluate:
- If the user's answer matches the correct answer, log: "Correct!"
- Otherwise, log: "Incorrect. The correct answer is [correctAnswer]."
Example:
Input:
evaluateAnswer("What is 5 + 5?", "10", TheCallBackFunction);
Expected Output:
- If user's input is "10": "Correct!"
- If user's input is "15": "Incorrect. The correct answer is 10."
*/
// ✍️ Solve it here ✍️