Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ccd4f6d

Browse files
second samllest finding complete
1 parent edc46b8 commit ccd4f6d

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

‎problme72/problem.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## Problem 72:
2+
3+
### Implement a JavaScript function to find the second smallest element in an array of numbers. The function should return the second smallest number.
4+

‎problme72/problme72.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
Implement a JavaScript function to find the second smallest element in an array of numbers. The function should return the second smallest number.
3+
*/
4+
5+
6+
const findSecondSmallest = arr => {
7+
const sortedNum = arr.sort((a, b) => a - b);
8+
const secondSmallest = sortedNum[1];
9+
return secondSmallest;
10+
}
11+
12+
const result = findSecondSmallest([1, 3, 2, 5, 4]);
13+
console.log(result);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /