Light Mode
Dark Mode
Validation error in commonWords function

I would like to give some feedback about ...

From: https://js.checkio.org/mission/common-words/solve/

HTTP_USER_AGENT:

Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0

function commonWords(first, second) {
    var list1 = first.split(",");
        var list2 = second.split(",");
        var res = [];            
        for(var i=0;i<list1.length;i++){
                for(var j=0;j<list2.length;j++){
                    if(list1[i]===list2[j]){
                        res.push(list1[i]);
                    }
                }
            }
            return res.join();
    } 

with test data > commonWords("one,two,three", "four,five,one,two,six,three");

should give "one,two,three" as a result but the assertions have "one,three,two" right next to 1,2,3

Please, check this assertions. Thanks.

  • bug
  • feedback
  • javascript
Created: May 26, 2017, 3:06 p.m.
Updated: Nov. 17, 2020, 2:17 p.m.
0
1
User avatar
abel406