← Back to challenges

Letters Shared between Two Words

JavaScriptHardarraysstringsdata_structures

Instructions

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

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Sum of Decimals