# JS Quiz: Easy: Simplest Regex Match

**URL:** <https://forum.kirupa.com/t/js-quiz-easy-simplest-regex-match/683211>\
**Category:** web dev\
**Created:** [September 1, 2026, 7:00am UTC](https://forum.kirupa.com/t/js-quiz-easy-simplest-regex-match/683211 "2026-09-01T07:00:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sora](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/sora/32/31259_2.png) [@sora](https://forum.kirupa.com/u/sora)\
**Post date:** [September 1, 2026, 7:00am UTC](https://forum.kirupa.com/t/js-quiz-easy-simplest-regex-match/683211/1 "2026-09-01T07:00:07Z")

</div>

What will be logged to the console by the `match` method?

```js
const text = "hello world";
const pattern = /world/;
const result = text.match(pattern);
console.log(result);

```

_Poll ([view on site](https://forum.kirupa.com/t/js-quiz-easy-simplest-regex-match/683211/1))_

---

<div class="post-metadata">

**Author:** ![VaultBoy](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/vaultboy/32/31832_2.png) [@VaultBoy](https://forum.kirupa.com/u/VaultBoy)\
**Post date:** [September 2, 2026, 7:20am UTC](https://forum.kirupa.com/t/js-quiz-easy-simplest-regex-match/683211/2 "2026-09-02T07:20:18Z")

</div>

Yeah it’s definitely the second option. the `match` method gives you back an array with all that extra info when it finds something, which is super handy. it’s not just the word itself, but also where it was found and the original string.

I always forget about the `groups: undefined` part though lol.

---

<div class="post-metadata">

**Author:** ![sora](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/sora/32/31259_2.png) [@sora](https://forum.kirupa.com/u/sora)\
**Post date:** [September 2, 2026, 8:00am UTC](https://forum.kirupa.com/t/js-quiz-easy-simplest-regex-match/683211/3 "2026-09-02T08:00:06Z")

</div>

**JS Quiz answer:** Option 2 (B).

**Correct choice:** [“world”, index: 6, input: “hello world”, groups: undefined]

**Why:**  
The `String.prototype.match()` method, when called with a regular expression, returns an array containing the match results. If the regex is global, it returns all matches. If not (as in this case), it returns the first match found, along with additional properties like `index` (the starting position of the match), `input` (the original string), and `groups` (if named capturing groups were used). Here, `/world/` matches ‘world’ starting at index 6.

**Go deeper:**

[Using JavaScript Prototype To Add New Properties](https://www.kirupa.com/html5/using_js_prototype_to_add_new_properties.htm)

**First-answer leaderboard**

1. @kirupa - 6 (firsts) 🏆
2. @Apexcodes - 5 (firsts)
3. @adnanahmed - 2 (firsts)
4. @emmawalter5 - 2 (firsts)
