Skip to content

Commit 444ada3

Browse files
authored
Create 1903-largest-odd-number-in-string.js
1 parent 64c9108 commit 444ada3

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

1903-largest-odd-number-in-string.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* @param {string} num
3+
* @return {string}
4+
*/
5+
const largestOddNumber = function(num) {
6+
let idx= -1
7+
for(let i = 0, n = num.length; i < n; i++) {
8+
if((+num[i]) % 2 === 1) idx = i
9+
}
10+
return num.slice(0, idx+1)
11+
};

0 commit comments

Comments
 (0)