--- title: Compare a list of strings id: 596e457071c35c882915b3e4 challengeType: 5 forumTopicId: 302235 --- ## Description
Given a list of arbitrarily many strings, implement a function for each of the following conditions:
## Instructions
## Tests
```yml tests: - text: allEqual should be a function. testString: assert(typeof allEqual === 'function'); - text: azSorted should be a function. testString: assert(typeof azSorted === 'function'); - text: allEqual(["AA", "AA", "AA", "AA"]) should return true. testString: assert(allEqual(testCases[0])); - text: azSorted(["AA", "AA", "AA", "AA"]) should return false. testString: assert(!azSorted(testCases[0])); - text: allEqual(["AA", "ACB", "BB", "CC"]) should return false. testString: assert(!allEqual(testCases[1])); - text: azSorted(["AA", "ACB", "BB", "CC"]) should return true. testString: assert(azSorted(testCases[1])); - text: allEqual([]) should return true. testString: assert(allEqual(testCases[2])); - text: azSorted([]) should return true. testString: assert(azSorted(testCases[2])); - text: allEqual(["AA"]) should return true. testString: assert(allEqual(testCases[3])); - text: azSorted(["AA"]) should return true. testString: assert(azSorted(testCases[3])); - text: allEqual(["BB", "AA"]) should return false. testString: assert(!allEqual(testCases[4])); - text: azSorted(["BB", "AA"]) should return false. testString: assert(!azSorted(testCases[4])); ```
## Challenge Seed
```js function allEqual(arr) { return true; } function azSorted(arr) { return true; } ```
### After Test
```js const testCases = [['AA', 'AA', 'AA', 'AA'], ['AA', 'ACB', 'BB', 'CC'], [], ['AA'], ['BB', 'AA']]; ```
## Solution
```js function allEqual(a) { let out = true; let i = 0; while (++i < a.length) { out = out && (a[i - 1] === a[i]); } return out; } function azSorted(a) { let out = true; let i = 0; while (++i < a.length) { out = out && (a[i - 1] < a[i]); } return out; } ```