From e8b092b95342c99be2c8b5a8acce2f75b36fb5b2 Mon Sep 17 00:00:00 2001 From: Aditi Jain Date: Sat, 8 Oct 2022 10:08:18 +0530 Subject: [PATCH] Fixed linting errors for build --- src/others/fibonacciMemory.js | 20 ++++++++++---------- src/searching/linearSearch.js | 22 +++++++++++----------- test/others/fibonacciMemory.spec.js | 2 +- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/others/fibonacciMemory.js b/src/others/fibonacciMemory.js index 256979bd..c1028b5c 100644 --- a/src/others/fibonacciMemory.js +++ b/src/others/fibonacciMemory.js @@ -16,17 +16,17 @@ * @module others/fibonacciMemory */ (function (exports) { - 'use strict'; + 'use strict'; - function fibonacciMemory(n) { - var i = 0; - var aux = [0, 1]; - while (n != i) { - aux[i + 2] = aux[i] + aux[i + 1]; - i++; - } - return aux[i]; + function fibonacciMemory(n) { + var i = 0; + var aux = [0, 1]; + while (n !== i) { + aux[i + 2] = aux[i] + aux[i + 1]; + i += 1; } + return aux[i]; + } - exports.fibonacciMemory = fibonacciMemory; + exports.fibonacciMemory = fibonacciMemory; })(typeof window === 'undefined' ? module.exports : window); diff --git a/src/searching/linearSearch.js b/src/searching/linearSearch.js index 7338a82f..09f11784 100644 --- a/src/searching/linearSearch.js +++ b/src/searching/linearSearch.js @@ -1,24 +1,24 @@ (function (exports) { - 'use strict'; + 'use strict'; /** * Searches for specific element in a given array * using the linear search algorithm * Time complexity: O(n) - * + * * @param {Array} array Input array * @param {Number} key the number whose index is to be found * @returns {Number} the index of the first instance of number or else -1 if not found */ - const linearSearch = (array, key) => { - for (let i = 0; i < array.length; i++) { - if (array[i] == key) { - return i; - } - } - return -1; + const linearSearch = (array, key) => { + for (let i = 0; i < array.length; i += 1) { + if (array[i] === key) { + return i; + } } + return -1; + } - exports.linearSearch = linearSearch; -})(typeof window === 'undefined' ? module.exports : window); \ No newline at end of file + exports.linearSearch = linearSearch; +})(typeof window === 'undefined' ? module.exports : window); diff --git a/test/others/fibonacciMemory.spec.js b/test/others/fibonacciMemory.spec.js index a2c5c118..f90ac1df 100644 --- a/test/others/fibonacciMemory.spec.js +++ b/test/others/fibonacciMemory.spec.js @@ -21,7 +21,7 @@ describe('fibonacci with Memory algorithm', function () { }); it('should return value 10 with input 55.', function () { expect(fibonacci(10)).toBe(55); - }); + }); it('should be 135301852344706760000 with input 98.', function () { expect(fibonacci(98)).toBe(135301852344706760000); });