Skip to content

Commit

Permalink
🚨 Fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
cHaLkdusT authored and mgechev committed Jan 17, 2023
1 parent 213636f commit cf8aa67
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions src/others/fibonacci.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
* @param {Number} n The nth position in fibonacci's sequence
*
* @module others/fibonacci
*/
*/
(function (exports) {
'use strict';

function fibonacci (n) {
function fibonacci(n) {
if (n > 97) {
throw 'Input too large, results in inaccurate fibonacci value.';
}
Expand Down
22 changes: 11 additions & 11 deletions src/others/fibonacciMemory.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@
* @param {Number} n The nth position in fibonacciMemory's sequence
*
* @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);
38 changes: 19 additions & 19 deletions src/searching/linearSearch.js
Original file line number Diff line number Diff line change
@@ -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
*/
/**
* 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);
exports.linearSearch = linearSearch;
})(typeof window === 'undefined' ? module.exports : window);
2 changes: 1 addition & 1 deletion test/others/fibonacciMemory.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down

0 comments on commit cf8aa67

Please sign in to comment.