Advertisement
v3ry

Untitled

May 25th, 2022
890
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function comp(array1, array2){
  2.   if (array1 == null || array2 == null) return false;
  3.  
  4.   const array3 = array2.map(val=>{
  5.     return Math.sqrt(val)
  6.   })
  7.   if (array1.length != array2.length) {
  8.     return false};
  9.   let once= false;
  10.  
  11.   array3.forEach((val1,index)=>{
  12.     once=false
  13.     for(val2 in array1){
  14.       if(val1 === array1[val2] && once==false){
  15.         once=true;
  16.         array1.splice(val2,1)
  17.     }
  18.     }
  19.    
  20.   })
  21.   return array1.length === 0? true:false
  22. }
Advertisement
RAW Paste Data Copied
Advertisement