Liliana797979

equal arrays2 - fundamentals

Jun 9th, 2021
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(arr1, arr2) {
  2.   let sum = 0;
  3.   for (let i in arr1) {
  4.       if (arr1[i] !== arr2[i]) {
  5.           console.log(`Arrays are not identical. Found difference at ${i} index`);
  6.           return;
  7.       }
  8.       sum += arr1[i] - 0; //ASCII hack
  9.   }
  10.  
  11.   console.log(`Arrays are identical. Sum: ${sum}`);
  12. }
Advertisement
Add Comment
Please, Sign In to add comment