mgechev / javascript-algorithms

💻 JavaScript implementations of computer science algorithms
https://mgechev.github.io/javascript-algorithms/
MIT License
7.83k stars 1.28k forks source link

Update knuth-morris-pratt using ES6 #213

Open amansaurabh opened 12 months ago

amansaurabh commented 12 months ago

Description:

Current Behavior:

The current implementation of the Knuth-Morris-Pratt (KMP) algorithm is written in a mix of ES5 and older JavaScript syntax. It consists of a function that efficiently searches for the position of the first occurrence of a specified value in a string.

Proposed Changes:

I propose updating the code to use ES6 features and syntax. This includes leveraging arrow functions, template literals, and other modern JavaScript constructs to enhance readability and maintainability.

Benefits:

Additional Information:

The updated code will maintain the functionality of the KMP algorithm while utilizing ES6 features to enhance its codebase. This update aims to align the algorithm with modern JavaScript practices.