Skip to content

Commit 941aed4

Browse files
authored
chore: Update README.md
1 parent fe0a2a2 commit 941aed4

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

README.md

+23
Original file line numberDiff line numberDiff line change
@@ -7115,6 +7115,29 @@ const numbers = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5];
71157115
console.log(findMin(numbers)); // Output: 1
71167116
```
71177117
7118+
Find the second largest number from the array given
7119+
7120+
```javascript
7121+
let array = [1, 8, 9, 40, 50];
7122+
7123+
const secondLar = (arr) => {
7124+
let first = -Infinity;
7125+
let second = -Infinity;
7126+
for (let i = 0; i < arr.length; i++){
7127+
7128+
if( arr[i] > first){
7129+
second = first;
7130+
first = arr[i];
7131+
} else if (arr[i] > second && arr[i] != first){
7132+
second = arr[i];
7133+
}
7134+
}
7135+
return second === -Infinity ? "No second largest number" : second;
7136+
}
7137+
7138+
console.log(secondLar(array));
7139+
```
7140+
71187141
Remove special characters from the given string without using built-in methods:
71197142
71207143
```javascript

0 commit comments

Comments
 (0)