Skip to content

Commit 7bcf484

Browse files
removed the redundant and unreachable codes
1 parent baa070c commit 7bcf484

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@ let testName = "Jerry";
55
const greeting = "hello";
66

77
function sayHello(greeting, name) {
8-
const greetingStr = greeting + ", " + name + "!";
8+
// const greetingStr = greeting + ", " + name + "!"; this line will also be removed because the we're trying to return something else, not the greetingStr and apparently it is a redundant code
99
return `${greeting}, ${name}!`;
10-
console.log(greetingStr);
10+
// console.log(greetingStr); this line will obviously be omitted as it is unreachable code because it is written after return. In fact, anything after return is not reachable and should be get rid of
1111
}
1212

13-
testName = "Aman";
14-
1513
const greetingMessage = sayHello(greeting, testName);
16-
17-
console.log(greetingMessage); // 'hello, Aman!'
14+
console.log(greetingMessage);

0 commit comments

Comments
 (0)