Letters Shared between Two Words

Published by kpetrov in

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

Examples

sharedLetters("apple", "meaty") ➞ 2
// Since "ea" is shared between "apple" and "meaty".

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

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

Notes

N/A

Watch a quick demo on how Edabit works.