Skip to content

Commit ef36391

Browse files
committed
fix mistakes in sayHello exercise
1 parent b31a586 commit ef36391

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

Sprint-3/3-dead-code/exercise-1.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// Find the instances of unreachable and redundant code - remove them!
22
// The sayHello function should continue to work for any reasonable input it's given.
33

4-
let testName = "Jerry";
4+
let testName; // = "Jerry"; -> we can initialize the variable without giving it a value because the testName is being reassigned later in the code. The value "Jerry" never appears in a function call.
55
const greeting = "hello";
66

77
function sayHello(greeting, name) {
8-
const greetingStr = greeting + ", " + name + "!";
8+
// const greetingStr = greeting + ", " + name + "!"; -> this line is not necessary because the returned string accomplishes the same thing, and the greetingStr is never being used. So it is redundant code and can be removed.
99
return `${greeting}, ${name}!`;
10-
console.log(greetingStr);
10+
// console.log(greetingStr); -> this line is never being executed because it comes after the return statement, so it never runs and can be removed.
1111
}
1212

1313
testName = "Aman";

0 commit comments

Comments
 (0)