← Back to challenges

No Hidden Fees

JavaScriptHardarraysnumberslanguage_fundamentalsvalidation

Instructions

Given an array of prices prices and a "supposed" total t, return true if there is a hidden fee added to the total (i.e. the total is greater than the sum of prices), otherwise return false.

Examples

hasHiddenFee(["$2", "$4", "$1", "$8"], "$15") ➞ false

hasHiddenFee(["$1", "$2", "$3"], "$6") ➞ false

hasHiddenFee(["$1"], "$4") ➞ true

Notes

  • Remember that each price is given as a string.
  • All $ signs will be at the beginning of the number.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Shhh Be Quiet Function