Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(arrOne, arrTwo) {
- if (arrOne.every(item => arrTwo.includes(item))) {
- console.log(`Arrays are identical. Sum: ${arrOne.map(Number).reduce((a, b) => a + b, 0)}`);
- } else {
- for (let i = 0; i < arrOne.length; i++) {
- if (arrOne[i] !== arrTwo[i]) {
- console.log(`Arrays are not identical. Found difference at ${i} index`);
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement