momo3141

task3

Jan 23rd, 2023
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const findByProjects = (obj,...allProjects) => {
  2.  
  3.     const compareArrays =  (arr1, arr2) => {
  4.  
  5.         if (arr1.length === arr2.length){
  6.  
  7.             for (let el of arr1){
  8.  
  9.                 if (!arr2.includes(el)){
  10.  
  11.                     return false
  12.  
  13.                 }
  14.  
  15.             }
  16.  
  17.             return true;
  18.  
  19.         } else {
  20.  
  21.             return false;
  22.  
  23.         }
  24.  
  25.  
  26.  
  27.  
  28.     }
  29.  
  30.     let result = obj.find(el => {
  31.  
  32.         return compareArrays((el.projects),allProjects)
  33.  
  34.     })
  35.  
  36.     return result;   
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment