?
. This checks for zero or one of the preceding element. You can think of this symbol as saying the previous element is optional.
For example, there are slight differences in American and British English and you can use the question mark to match both spellings.
```js
let american = "color";
let british = "colour";
let rainbowRegex= /colou?r/;
rainbowRegex.test(american); // Returns true
rainbowRegex.test(british); // Returns true
```
favRegex
to match both the American English (favorite) and the British English (favourite) version of the word.
?
.
testString: favRegex.lastIndex = 0; assert(favRegex.source.match(/\?/).length > 0);
- text: Your regex should match "favorite"
testString: favRegex.lastIndex = 0; assert(favRegex.test("favorite"));
- text: Your regex should match "favourite"
testString: favRegex.lastIndex = 0; assert(favRegex.test("favourite"));
- text: Your regex should not match "fav"
testString: favRegex.lastIndex = 0; assert(!favRegex.test("fav"));
```