I am looking for the easiest way to find the longest common suffix of two strings in JavaScript.
I found a question about longest common prefix but nothing for suffix.
I am looking for the easiest way to find the longest common suffix of two strings in JavaScript.
I found a question about longest common prefix but nothing for suffix.
3
Answers
For fun, I am providing an alternate solution which first transforms the strings into arrays then finds the common suffix.
You can use this: