FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fixed linting errors for failing build by AditiJain2826 · Pull Request #200 · mgechev/javascript-algorithms · GitHub

Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .js  (3) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
20 changes: 10 additions & 10 deletions src/others/fibonacciMemory.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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);
22 changes: 11 additions & 11 deletions src/searching/linearSearch.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
*/

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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Back | FazBrowse Home | New Git URL