← Back to challenges

Ransom Letter

JavaScriptHardstringsvalidation

Instructions

Write a function that returns true if you can use the letters of the first string to create the second string. Letters are case sensitive.

Examples

canBuild("aPPleAL", "PAL") ➞ true

canBuild("aPPleAL", "apple") ➞ false

canBuild("a", "") ➞ true

canBuild("aa", "aaa") ➞ false

Notes

Letters in the first string can be used only once.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.