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.5 KiB
1.5 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 6a22d77ddf034bc4e35b1d59 | Challenge 352: Contrast Rating 1 | 28 | challenge-352 |
--description--
Given a contrast ratio and a boolean indicating whether the text is large, return the WCAG rating using the following table:
| Rating | Normal Text | Large Text |
|---|---|---|
"AAA" |
7.0+ | 4.5+ |
"AA" |
4.5+ | 3.0+ |
"Fail" |
below 4.5 | below 3.0 |
--hints--
getContrastRating("7.5", false) should return "AAA".
assert.equal(getContrastRating("7.5", false), "AAA");
getContrastRating("4.8", false) should return "AA".
assert.equal(getContrastRating("4.8", false), "AA");
getContrastRating("4.2", false) should return "Fail".
assert.equal(getContrastRating("4.2", false), "Fail");
getContrastRating("4.5", true) should return "AAA".
assert.equal(getContrastRating("4.5", true), "AAA");
getContrastRating("3.0", true) should return "AA".
assert.equal(getContrastRating("3.0", true), "AA");
getContrastRating("2.7", false) should return "Fail".
assert.equal(getContrastRating("2.7", false), "Fail");
--seed--
--seed-contents--
function getContrastRating(ratio, isLargeText) {
return ratio;
}
--solutions--
function getContrastRating(ratio, isLargeText) {
if (isLargeText) {
if (ratio >= 4.5) return "AAA";
if (ratio >= 3.0) return "AA";
} else {
if (ratio >= 7.0) return "AAA";
if (ratio >= 4.5) return "AA";
}
return "Fail";
}