← Back to challenges

Hashes and Pluses

JavaScriptHardstringsloopsregex

Instructions

Create a function that returns the number of hashes and pluses in a string.

Examples

hashPlusCount("###+") ➞ [3, 1]

hashPlusCount("##+++#") ➞ [3, 3]

hashPlusCount("#+++#+#++#") ➞ [4, 6]

hashPlusCount("") ➞ [0, 0]

Notes

  • Return [0, 0] for an empty string.
  • Return in the order of [hashes, pluses].
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Secret Society