-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctional Porgramming lab Solution.js
More file actions
33 lines (28 loc) · 1.15 KB
/
functional Porgramming lab Solution.js
File metadata and controls
33 lines (28 loc) · 1.15 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
// Task 1: Build a function-based console log message generator
function consoleStyler(color, background, fontSize, txt) {
const message = "%c" + txt;
let style = `color: ${color};`;
style += `background: ${background};`;
style += `font-size: ${fontSize};`;
console.log(message, style);
}
// Task 2: Build another console log message generator
function celebrateStyler(reason) {
const fontStyle = "color: tomato; font-size: 50px";
if (reason === "birthday") {
console.log("%cHappy birthday", fontStyle);
} else if (reason === "champions") {
console.log("%cCongrats on the title!", fontStyle);
} else {
console.log("%cMessage or style not defined.", fontStyle);
}
}
// Task 3: Run both the consoleStyler and the celebrateStyler functions
consoleStyler('#1d5c63', '#ede6db', '40px', 'Congrats!');
celebrateStyler('birthday');
// Task 4: Insert a congratulatory and custom message
function styleAndCelebrate(color, background, fontSize, txt, reason) {
consoleStyler(color, background, fontSize, txt);
celebrateStyler(reason);
}
styleAndCelebrate('ef7c8e', 'fae8e0', '30px', 'You made it!', 'champions');