diff --git a/curriculum/challenges/english/14-responsive-web-design-22/learn-typography-by-building-a-nutrition-label/615f7de4487b64919bb4aa5e.md b/curriculum/challenges/english/14-responsive-web-design-22/learn-typography-by-building-a-nutrition-label/615f7de4487b64919bb4aa5e.md index 8384abae4e7..5ccebcaba77 100644 --- a/curriculum/challenges/english/14-responsive-web-design-22/learn-typography-by-building-a-nutrition-label/615f7de4487b64919bb4aa5e.md +++ b/curriculum/challenges/english/14-responsive-web-design-22/learn-typography-by-building-a-nutrition-label/615f7de4487b64919bb4aa5e.md @@ -20,43 +20,54 @@ assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.loca Your new `p` element should have the text `Cholesterol 0mg 0%`. ```js -assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.innerText?.match(/Cholesterol[\s|\n]+0mg[\s|\n]+0%/)); +const text = document.querySelector('.daily-value.small-text')?.lastElementChild?.textContent?.trim()?.replace(/\n/g, ' ')?.replace(/\s\s+/g, ' '); +assert(text === 'Cholesterol 0mg 0%'); ``` -Your new `p` element should have three `span` elements. +Your new `p` element should have exactly three `span` elements. ```js assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.querySelectorAll('span')?.length === 3); ``` -Your first `span` `Cholesterol` element should have the `class` attribute set to `bold`. +The text `Cholesterol` should be nested in a `span`. ```js -assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.firstElementChild?.firstElementChild?.classList?.contains('bold')); +const spans = [...document.querySelector('.daily-value.small-text')?.lastElementChild?.querySelectorAll('span')]; +const cholesterolSpan = spans.filter(span => span?.innerHTML?.match(/^[\s\n]*Cholesterol[\s\n]*$/)); +assert(cholesterolSpan.length === 1); ``` -Your first `span` element should wrap the text `Cholesterol 0mg`. +Your `Cholesterol` `span` should have the `class` attribute set to `bold`. ```js -assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.firstElementChild?.innerText?.match(/Cholesterol[\s|\n]+0mg/)); +const spans = [...document.querySelector('.daily-value.small-text')?.lastElementChild?.querySelectorAll('span')]; +const cholesterolSpan = spans.filter(span => span?.innerHTML?.match(/^[\s\n]*Cholesterol[\s\n]*$/)); +assert(cholesterolSpan[0]?.classList?.contains('bold')); ``` -Your first `span` element should wrap the text `Cholesterol`. +The text `0%` should be nested in a `span`. ```js -assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.firstElementChild?.firstElementChild?.innerText === 'Cholesterol'); +const spans = [...document.querySelector('.daily-value.small-text')?.lastElementChild?.querySelectorAll('span')]; +const zeroPercentSpan = spans.filter(span => span?.innerHTML?.match(/^[\s\n]*0%[\s\n]*$/)); +assert(zeroPercentSpan.length === 1); ``` -Your second `span` element should have the `class` attribute set to `bold`. +Your `0%` `span` should have the `class` attribute set to `bold`. ```js -assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.lastElementChild?.classList?.contains('bold')); +const spans = [...document.querySelector('.daily-value.small-text')?.lastElementChild?.querySelectorAll('span')]; +const zeroPercentSpan = spans.filter(span => span?.innerHTML?.match(/^[\s\n]*0%[\s\n]*$/)); +assert(zeroPercentSpan[0]?.classList?.contains('bold')); ``` -Your second `span` element should wrap the text `0%`. +Your `Cholesterol` `span` and your `0mg` text should be wrapped in a `span`. ```js -assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.lastElementChild?.innerText === '0%'); +const spans = [...document.querySelector('.daily-value.small-text')?.lastElementChild?.querySelectorAll('span')]; +const cholesterolZeroSpan = spans.filter(span => span?.innerText === 'Cholesterol 0mg'); +assert(cholesterolZeroSpan.length === 1); ``` # --seed--