Array comparison solved in javascript