Skip to content
Advertisement

Count the number of matching words between two strings

Hello I would like to ask some help how I can do this in Jquery

Count the number of matching words (in order) between two strings so I can generate accuracy.

JavaScript

Output: 4

Accuracy is (4 correct words/7 words to check) = 57%

Any idea will be appreciated

Advertisement

Answer

You could split each string to words and match the same words by using filter

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement