Skip to content

Commit 8c21d6e

Browse files
committed
fix: add conditions
1 parent 3e1b5fd commit 8c21d6e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

divide-and-conquer-algorithm.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ function divideAndConquer(arr: number[], target: number): number | null {
2626
}
2727

2828
const array = [1, 3, 5, 7, 9, 11, 13, 15, 17];
29-
const targetElement = 7;
29+
const targetElement = 3;
3030

3131
let result = divideAndConquer(array, targetElement);
32-
console.log(result);
32+
if (result === null) {
33+
console.log("item not found");
34+
} else {
35+
console.log(result);
36+
}

0 commit comments

Comments
 (0)