Identity Crisis

MediumAcc. 91.4%
+35 XP 15

Perfectly Mirror

Two arrays are identical if they have the same number of elements and every element at index i is the same in both.

The Assignment

Your function receives arr1 and arr2.

  1. First, check if the lengths are different. If so, print false and exit.
  2. Use a loop to compare arr1[i] with arr2[i].
  3. If any mismatch is found, print false and exit.
  4. If the loop finishes, print true.

01EXAMPLE 1

Inputarr1=[1, 2], arr2=[1, 2]
Outputtrue

Explanation: Identical.

Constraints

  • Return a boolean string.
  • Linear O(n) scan.
ArraysLogic
JavaScript
Loading...
2 Hidden

Input Arguments

arr1[1,2,3]
arr2[1,2,3]

Expected Output

true

Click RUN to test your solution