fix(curriculum): add optional chaining to prevent "TypeError" in null checks (#59086)

This commit is contained in:
Mohamad Salman
2025-03-03 18:56:58 +01:00
committed by GitHub
parent 9aae2307e5
commit 250c4d4730
@@ -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--