Code Lab

Jewels and stones

EasyMap and Set4 min

Every character of the string jewels is one kind of jewel. Every character of the string stones is one stone you have.

Write a function countJewels(jewels, stones) that counts how many of your stones are jewels. Case matters, a and A are different kinds.

Examples

countJewels('aA', 'aAAbbbb')

Returns 3

The jewels here are one `a` and two `A` stones.
countJewels('z', 'ZZ')

Returns 0

`Z` and `z` are different kinds.

Source

Loading the editor...
  1. InputcountJewels('aA', 'aAAbbbb')
    Expected3
  2. InputcountJewels('z', 'ZZ')
    Expected0
  3. InputcountJewels('ab', 'abba')
    Expected4

Hidden tests run on Submit.