JavaScript Fundamentals - Arrays - Задача 7: Equal Arrays
Здравейте колеги,
Бихте ли ми помогнали с решението на задача 7 от лекцията за масиви (Equal Arrays). Успях да взема 75/100 в Judge.
Условие:
Write a program which receives two string arrays and print on the console whether they are identical or NOT.
Arrays are identical if their elements are equal. If the arrays are identical find the sum of the first one and print on the console following message:
'Arrays are identical. Sum: {sum}'
If the arrays are NOT identical find the first index where the arrays differ and print on the console following message:
'Arrays are not identical. Found difference at {index} index'.
Examples
Input |
Output |
['10','20','30'], ['10','20','30'] |
Arrays are identical. Sum: 60 |
['1','2','3','4','5'], ['1','2','4','4','5'] |
Arrays are not identical. Found difference at 2 index |
['1'], ['10'] |
Arrays are not identical. Found difference at 0 index |
Ето и моето решение:
https://pastebin.com/k0wLJzeN
Благодаря предварително.
Много благодаря за помощта.
Успех и на вас!