Skip to content

Commit 58517d5

Browse files
author
Gonzalo Diaz
committed
Prefer Math.max() to simplify ternary expressions.
Ternary expressions should be replaced with "Math.min()" or "Math.max()" for simple comparisons javascript:S7766
1 parent d953407 commit 58517d5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/hackerrank/interview_preparation_kit/dynamic_programming/max_array_sum.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
*/
55

66
const bigIntMax = (...args) =>
7-
args.reduce((m, e) => (e > m ? e : m), BigInt(0));
7+
args.reduce((m, e) => {
8+
const _e = BigInt(e);
9+
const _m = BigInt(m);
10+
return _e > _m ? _e : _m;
11+
}, BigInt(0));
812

913
function maxSubsetSum(arr) {
1014
const arrCopy = arr.map(BigInt);

0 commit comments

Comments
 (0)