Letters Shared Between Two Words

Published by bangyen in

Create a function that returns the number of characters shared between two words.

Examples

shared_letters("apple", "meaty") ➞ 2
# Since "ea" is shared between "apple" and "meaty".

shared_letters("fan", "forsook") ➞ 1

shared_letters("spout", "shout") ➞ 4

Notes

N/A

Watch a quick demo on how Edabit works.