Match element content and asign point per match.

Match element content and asign point per match.

I'm trying to compare orange and red boxes respectively to the green box, find LI's with matching contents and then assign points to them. With WHat I have so far, It doesn't asign the points correctly. E.g

1. The orange box shoud have 40 points because 4 ofs it Li contents all have matches in the Green box.

1. The orange box shoud have 430 points because 3 of its Li contents all have matches in the Green box.

How can I achieve this.


My code is as shown below.

  1. $(document).each(function () {
  2.     var pMatch = $('ol li').map(function () {
  3.         return $(this).text()
  4.     })
  5.     var sMatch = $('.three li').map(function () {
  6.         return $(this).text()
  7.     })
  8.     $.each(pMatch, function (i, h) {
  9.         if (h === sMatch[i]) {
  10.             var uSp = $("ol li").eq(i).length * 10;
  11.             $( "ol li:last-of-type" ).text( "" + uSp + " Points");
  12.         }
  13.     });

Jsfiddle link