Advertisement
SIRAKOV4444

Untitled

Mar 27th, 2020
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. function arrays(array1, array2) {
  2.  
  3. let sum =0;
  4.  
  5. let isRight = true;
  6. for (let hmm = 0; hmm <= array1.length-1; hmm++) {
  7. array1[hmm]=Number(array1[hmm]);
  8. array2[hmm]=Number(array2[hmm]);
  9. sum+=(array1[hmm]);
  10. if (array1[hmm] !== array2[hmm]) {
  11. let thisNumber = (hmm);
  12. console.log('Arrays are not identical. Found difference at ' + thisNumber + ' index');
  13. isRight = false;
  14. break;
  15.  
  16. }
  17. }
  18. if (isRight === true) {
  19. console.log('Arrays are identical. Sum: ' + Number(sum));
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement