mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-10-24 23:49:06 +08:00
fix(curriculum): add optional chaining to prevent "TypeError" in null checks (#59086)
This commit is contained in:
+1
-6
@@ -45,12 +45,7 @@ The Cats `img` element should have an `alt` attribute with the value `Five cats
|
||||
|
||||
```js
|
||||
const catsImg = document.querySelectorAll('figure > img')[1];
|
||||
assert(
|
||||
catsImg
|
||||
.getAttribute('alt')
|
||||
.replace(/\s+/g, ' ')
|
||||
.match(/^Five cats looking around a field\.?$/i)
|
||||
);
|
||||
assert.match(catsImg?.getAttribute('alt')?.replace(/\s+/g, ' '), /^Five cats looking around a field\.?$/i);
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
Reference in New Issue
Block a user