dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
1.0 KiB
1.0 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 698a1a73ade5ac0e19180fa6 | Challenge 203: Flattened | 28 | challenge-203 |
--description--
Given an array, determine if it is flat.
- An array is flat if none of its elements are arrays.
--hints--
isFlat([1, 2, 3, 4]) should return true.
assert.isTrue(isFlat([1, 2, 3, 4]));
isFlat([1, [2, 3], 4]) should return false.
assert.isFalse(isFlat([1, [2, 3], 4]));
isFlat([1, 0, false, true, "a", "b"]) should return true.
assert.isTrue(isFlat([1, 0, false, true, "a", "b"]));
isFlat(["a", [0], "b", true]) should return false.
assert.isFalse(isFlat(["a", [0], "b", true]));
isFlat([1, [2, [3, [4, [5]]]], 6]) should return false.
assert.isFalse(isFlat([1, [2, [3, [4, [5]]]], 6]));
--seed--
--seed-contents--
function isFlat(arr) {
return arr;
}
--solutions--
function isFlat(arr) {
for (let el of arr) {
if (Array.isArray(el)) return false;
}
return true;
}