-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGreetings.js
More file actions
31 lines (22 loc) · 835 Bytes
/
Greetings.js
File metadata and controls
31 lines (22 loc) · 835 Bytes
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
/* ------------------------------------------------------------------------
Jenny has written a function that returns a greeting for a user.
However, she's in love with Johnny, and would like to greet him
slightly different. She added a special case to her function, but
she made a mistake.
Can you help her?
let greet = name => `Hello, ${name == "Johnny" ? "my love" : name}!`;
------------------------------------------------------------------------ */
/*
Starter code:
function greet(name) {
return "Hello, " + name + "!";
if (name === "Johnny") return "Hello, my love!";
}
*/
function greet(name) {
return `Hello, ${name === "Johnny" ? "my love" : name}!`;
}
/*
Alternative solution
*/
let greet = (name) => `Hello, ${name === "Johnny" ? "my love" : name}!`;