--- title: Compare a list of strings id: 596e457071c35c882915b3e4 challengeType: 5 --- ## Description

Given a list of arbitrarily many strings, implement a function for each of the following conditions:

test if they are all lexically equal test if every string is lexically less than the one after it (i.e. whether the list is in strict ascending order)
## Instructions
## Tests
```yml tests: - text: allEqual is a function. testString: assert(typeof allEqual === 'function', 'allEqual is a function.'); - text: azSorted is a function. testString: assert(typeof azSorted === 'function', 'azSorted is a function.'); - text: allEqual(["AA", "AA", "AA", "AA"]) returns true. testString: assert(allEqual(testCases[0]), 'allEqual(["AA", "AA", "AA", "AA"]) returns true.'); - text: azSorted(["AA", "AA", "AA", "AA"]) returns false. testString: assert(!azSorted(testCases[0]), 'azSorted(["AA", "AA", "AA", "AA"]) returns false.'); - text: allEqual(["AA", "ACB", "BB", "CC"]) returns false. testString: assert(!allEqual(testCases[1]), 'allEqual(["AA", "ACB", "BB", "CC"]) returns false.'); - text: azSorted(["AA", "ACB", "BB", "CC"]) returns true. testString: assert(azSorted(testCases[1]), 'azSorted(["AA", "ACB", "BB", "CC"]) returns true.'); - text: allEqual([]) returns true. testString: assert(allEqual(testCases[2]), 'allEqual([]) returns true.'); - text: azSorted([]) returns true. testString: assert(azSorted(testCases[2]), 'azSorted([]) returns true.'); - text: allEqual(["AA"]) returns true. testString: assert(allEqual(testCases[3]), 'allEqual(["AA"]) returns true.'); - text: azSorted(["AA"]) returns true. testString: assert(azSorted(testCases[3]), 'azSorted(["AA"]) returns true.'); - text: allEqual(["BB", "AA"]) returns false. testString: assert(!allEqual(testCases[4]), 'allEqual(["BB", "AA"]) returns false.'); - text: azSorted(["BB", "AA"]) returns false. testString: assert(!azSorted(testCases[4]), 'azSorted(["BB", "AA"]) returns false.'); ```
## Challenge Seed
```js function allEqual (arr) { // Good luck! return true; } function azSorted (arr) { // Good luck! 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; } ```