Skip to content

Commit b0bcdb1

Browse files
author
Gonzalo Diaz
committed
[BUGFIX] [Hacker Rank] Interview Preparation Kit: Arrays: New Year Chaos. Sonarcloud issue javascript:S3800 fixed ✅.
Refactor this function to always return the same type.
1 parent 619e424 commit b0bcdb1

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/hackerrank/interview_preparation_kit/arrays/new_year_chaos.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export function minimumBribes(q) {
2929

3030
export function minimumBribesTransform(queue) {
3131
try {
32-
return minimumBribes(queue);
32+
return minimumBribes(queue).toString(10);
3333
} catch (e) {
3434
return TOO_CHAOTIC_ERROR;
3535
}

src/hackerrank/interview_preparation_kit/arrays/new_year_chaos.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { logger as console } from '../../../logger.js';
44
import { minimumBribesTransform, TOO_CHAOTIC_ERROR } from './new_year_chaos.js';
55

66
const TEST_CASES = [
7-
{ title: 'Test Case 0-0', input: [2, 1, 5, 3, 4], expected: 3 },
7+
{ title: 'Test Case 0-0', input: [2, 1, 5, 3, 4], expected: '3' },
88
{
99
title: 'Test Case 0-1',
1010
input: [2, 5, 1, 3, 4],
@@ -15,8 +15,8 @@ const TEST_CASES = [
1515
input: [5, 1, 2, 3, 7, 8, 6, 4],
1616
expected: TOO_CHAOTIC_ERROR
1717
},
18-
{ title: 'Test Case 1-2', input: [1, 2, 5, 3, 7, 8, 6, 4], expected: 7 },
19-
{ title: 'Test Case 2', input: [1, 2, 5, 3, 4, 7, 8, 6], expected: 4 }
18+
{ title: 'Test Case 1-2', input: [1, 2, 5, 3, 7, 8, 6, 4], expected: '7' },
19+
{ title: 'Test Case 2', input: [1, 2, 5, 3, 4, 7, 8, 6], expected: '4' }
2020
];
2121

2222
describe('new_year_chaos', () => {

0 commit comments

Comments
 (0)