-
-
Notifications
You must be signed in to change notification settings - Fork 335
Expand file tree
/
Copy pathexercise-1.js
More file actions
39 lines (27 loc) · 865 Bytes
/
exercise-1.js
File metadata and controls
39 lines (27 loc) · 865 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
32
33
34
35
36
37
38
/**
* Original code:
*
// Find the instances of unreachable and redundant code - remove them!
// The sayHello function should continue to work for any reasonable input it's given.
let testName = "Jerry";
const greeting = "hello";
function sayHello(greeting, name) {
const greetingStr = greeting + ", " + name + "!";
return `${greeting}, ${name}!`;
console.log(greetingStr);
}
testName = "Aman";
const greetingMessage = sayHello(greeting, testName);
console.log(greetingMessage); // 'hello, Aman!'
*
* End of code
*/
// The sayHello function should continue to work for any reasonable input it's given.
let testName = "Jerry";
const greeting = "hello";
function sayHello(greeting, name) {
return `${greeting}, ${name}!`;
}
testName = "Aman";
const greetingMessage = sayHello(greeting, testName);
console.log(greetingMessage); // 'hello, Aman!'