How to use higher order functions for Diff Two Arrays challenge

I have solved this challenge with 2 for loops with too much time complexity. I want to understand how to convert this code into a higher-order function and use the filter in it, please explain that in detail? I want to make the code shorter and optimize as well

function diffArray(arr1, arr2) {
  var newArr = [];
var count=0;
    var ar=arr1.concat(arr2);
  ar= ar.sort();
    for(var i=0;i<ar.length;i++)
       for(var j=0;j<ar.length;j++)
               //console.log(ar[i]+" == "+ar[j] +" for if count" + " value of count "+ count);
           { //console.log("for else");
            //console.log("Value of count <2 "+ count)
//    console.log(newArr);
    return newArr;


diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);

Instead of us showing you how to use a higher order function, you should think about what functions you would want to use and try to implement the change yourself. We can guide you along, but you will need to first try yourself.

1 Like

sure, I am trying to implement myself first then if stuck somewhere I will asking for help!