From 1b4af50a75df6640fbbef8f1696a3863225cccb7 Mon Sep 17 00:00:00 2001 From: Alex Goldsmith <46906584+alexgoldsmith@users.noreply.github.com> Date: Mon, 30 Jun 2025 10:45:55 -0500 Subject: [PATCH] fix(curriculum): add .trim() to innerText assertions (#61109) --- .../5dfb6a35eacea3f48c6300b4.md | 2 +- .../5ef9b03c81a63668521804d4.md | 2 +- .../5efc575c8d6a74d05e68af77.md | 2 +- .../671141feba228a35cefba82d.md | 4 ++-- .../workshop-cat-photo-app/5dfb6a35eacea3f48c6300b4.md | 2 +- .../workshop-cat-photo-app/5ef9b03c81a63668521804d4.md | 2 +- .../workshop-cat-photo-app/671141feba228a35cefba82d.md | 4 ++-- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/curriculum/challenges/english/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5dfb6a35eacea3f48c6300b4.md b/curriculum/challenges/english/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5dfb6a35eacea3f48c6300b4.md index 9400315f7df..0ce679fed80 100644 --- a/curriculum/challenges/english/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5dfb6a35eacea3f48c6300b4.md +++ b/curriculum/challenges/english/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5dfb6a35eacea3f48c6300b4.md @@ -67,7 +67,7 @@ Your `figcaption` element's text should be `Cats love lasagna.` You have either ```js assert( - document.querySelector('figcaption').innerText.match(/Cats love lasagna.?$/i) + document.querySelector('figcaption').innerText.trim().match(/^Cats love lasagna\.?$/i) ); ``` diff --git a/curriculum/challenges/english/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804d4.md b/curriculum/challenges/english/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804d4.md index 1b16151f138..d7492ae856f 100644 --- a/curriculum/challenges/english/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804d4.md +++ b/curriculum/challenges/english/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5ef9b03c81a63668521804d4.md @@ -32,7 +32,7 @@ assert( document .querySelectorAll('figcaption')[1] .querySelector('strong') - .innerText.toLowerCase() === 'hate' + .innerText.trim().toLowerCase() === 'hate' ); ``` diff --git a/curriculum/challenges/english/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5efc575c8d6a74d05e68af77.md b/curriculum/challenges/english/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5efc575c8d6a74d05e68af77.md index 456bac4c6a4..75cd6f3f76c 100644 --- a/curriculum/challenges/english/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5efc575c8d6a74d05e68af77.md +++ b/curriculum/challenges/english/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/5efc575c8d6a74d05e68af77.md @@ -47,7 +47,7 @@ On the right side of your new checkbox, there should be `label` element with the const nextElementSibling = document.querySelectorAll('input[type="checkbox"]')?.[2]?.nextElementSibling; assert.isOk( nextElementSibling?.nodeName === 'LABEL' && - nextElementSibling?.innerText?.replace(/\s+/g, '')?.match(/^Energetic$/i) + nextElementSibling?.innerText?.trim().match(/^Energetic$/i) ); ``` diff --git a/curriculum/challenges/english/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/671141feba228a35cefba82d.md b/curriculum/challenges/english/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/671141feba228a35cefba82d.md index 90d07df4fdb..3bea54f41ee 100644 --- a/curriculum/challenges/english/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/671141feba228a35cefba82d.md +++ b/curriculum/challenges/english/14-responsive-web-design-22/learn-html-by-building-a-cat-photo-app/671141feba228a35cefba82d.md @@ -22,7 +22,7 @@ assert.exists(document.querySelector('p')?.querySelector('a')); The anchor text should be `cute cats`. ```js -assert.strictEqual(document.querySelector('a')?.innerText, "cute cats"); +assert.strictEqual(document.querySelector('a')?.innerText.trim(), "cute cats"); ``` The `href` attribute of the new anchor element should be `https://cdn.freecodecamp.org/curriculum/cat-photo-app/running-cats.jpg`. @@ -40,7 +40,7 @@ assert.strictEqual(code.indexOf("cute cats"),code.lastIndexOf("cute cats")); The text of the `p` element should still be `Everyone loves cute cats online!`. ```js -assert.strictEqual(document.querySelector('p')?.innerText, "Everyone loves cute cats online!"); +assert.strictEqual(document.querySelector('p')?.innerText.trim(), "Everyone loves cute cats online!"); ``` # --seed-- diff --git a/curriculum/challenges/english/25-front-end-development/workshop-cat-photo-app/5dfb6a35eacea3f48c6300b4.md b/curriculum/challenges/english/25-front-end-development/workshop-cat-photo-app/5dfb6a35eacea3f48c6300b4.md index dd1e2767a90..9ab4ae02042 100644 --- a/curriculum/challenges/english/25-front-end-development/workshop-cat-photo-app/5dfb6a35eacea3f48c6300b4.md +++ b/curriculum/challenges/english/25-front-end-development/workshop-cat-photo-app/5dfb6a35eacea3f48c6300b4.md @@ -64,7 +64,7 @@ Your `figcaption` element's text should be `Cats love lasagna.` You have either ```js assert.match( - document.querySelector('figcaption')?.innerText, /Cats love lasagna.?$/i + document.querySelector('figcaption')?.innerText?.trim(), /Cats love lasagna.?$/i ); ``` diff --git a/curriculum/challenges/english/25-front-end-development/workshop-cat-photo-app/5ef9b03c81a63668521804d4.md b/curriculum/challenges/english/25-front-end-development/workshop-cat-photo-app/5ef9b03c81a63668521804d4.md index d3ae8f588bf..cd9320ff652 100644 --- a/curriculum/challenges/english/25-front-end-development/workshop-cat-photo-app/5ef9b03c81a63668521804d4.md +++ b/curriculum/challenges/english/25-front-end-development/workshop-cat-photo-app/5ef9b03c81a63668521804d4.md @@ -32,7 +32,7 @@ assert.equal( document .querySelectorAll('figcaption')[1] ?.querySelector('strong') - ?.innerText.toLowerCase(), 'hate' + ?.innerText?.trim().toLowerCase(), 'hate' ); ``` diff --git a/curriculum/challenges/english/25-front-end-development/workshop-cat-photo-app/671141feba228a35cefba82d.md b/curriculum/challenges/english/25-front-end-development/workshop-cat-photo-app/671141feba228a35cefba82d.md index 90d07df4fdb..70fb4e82b0d 100644 --- a/curriculum/challenges/english/25-front-end-development/workshop-cat-photo-app/671141feba228a35cefba82d.md +++ b/curriculum/challenges/english/25-front-end-development/workshop-cat-photo-app/671141feba228a35cefba82d.md @@ -22,7 +22,7 @@ assert.exists(document.querySelector('p')?.querySelector('a')); The anchor text should be `cute cats`. ```js -assert.strictEqual(document.querySelector('a')?.innerText, "cute cats"); +assert.strictEqual(document.querySelector('a')?.innerText?.trim(), "cute cats"); ``` The `href` attribute of the new anchor element should be `https://cdn.freecodecamp.org/curriculum/cat-photo-app/running-cats.jpg`. @@ -40,7 +40,7 @@ assert.strictEqual(code.indexOf("cute cats"),code.lastIndexOf("cute cats")); The text of the `p` element should still be `Everyone loves cute cats online!`. ```js -assert.strictEqual(document.querySelector('p')?.innerText, "Everyone loves cute cats online!"); +assert.strictEqual(document.querySelector('p')?.innerText?.trim(), "Everyone loves cute cats online!"); ``` # --seed--