diff --git a/Dynamic-Programming/KadaneAlgo.js b/Dynamic-Programming/KadaneAlgo.js index 5d60103f9..f5b8c937a 100644 --- a/Dynamic-Programming/KadaneAlgo.js +++ b/Dynamic-Programming/KadaneAlgo.js @@ -23,13 +23,4 @@ function kadaneAlgo (array) { return maxSum // This function returns largest sum contiguous sum in a array } -function main () { - // input array - const myArray = [1, 2, 3, 4, -6] - // calling the function - const result = kadaneAlgo(myArray) - // result is the variable for storing the ourput of kadaneAlgo function - console.log(result) -} -main() -module.exports = { kadaneAlgo } +export { kadaneAlgo } diff --git a/Dynamic-Programming/tests/KadaneAlgo.test.js b/Dynamic-Programming/tests/KadaneAlgo.test.js index e0b7e6fd4..3155e6e82 100644 --- a/Dynamic-Programming/tests/KadaneAlgo.test.js +++ b/Dynamic-Programming/tests/KadaneAlgo.test.js @@ -1,8 +1,8 @@ -const fc = require('../kadaneAlgo') -test('test1', () => { +import { kadaneAlgo } from '../KadaneAlgo' +test('it is being checked that 15 is the answer to the corresponding array input', () => { expect(fc.kadaneAlgo([1, 2, 3, 4, 5])).toBe(15) }) -test('test2', () => { +test('it is being checked that 5 is the answer to the corresponding array input', () => { expect(fc.kadaneAlgo([-1, -2, -3, -4, 5])).toBe(5) })