Check If Two String Arrays are Equivalent
In this coding lab, you will determine if two given string arrays
word2 represent the same string. A string is represented by an array if the array elements concatenated in order forms the string. You have to write a function
arrayStringsAreEqual that returns
true if the two arrays represent the same string, and
Consider the following examples:
const word1 = ["ab", "c"]; const word2 = ["a", "bc"]; arrayStringsAreEqual(word1, word2); // Output: true
Explanation: word1 represents string "ab" + "c" -> "abc" word2 represents string "a" + "bc" -> "abc" The strings are the same, so return true.
const word1 = ["a", "cb"]; const word2 = ["ab", "c"]; arrayStringsAreEqual(word1, word2); // Output: false
const word1 = ["abc", "d", "defg"]; const word2 = ["abcddefg"]; arrayStringsAreEqual(word1, word2); // Output: true
1 <= word1.length, word2.length <= 103
1 <= word1[i].length, word2[i].length <= 103
1 <= sum(word1[i].length), sum(word2[i].length) <= 103
word2[i]consist of lowercase letters.
- Export your function
arrayStringsAreEqualusing ESM export.
- Confirm that your function works correctly for the provided examples, as well as additional cases.
Note that you must export any function or variable that you use in your code, as this will be required for evaluation during testing.