Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Please specify a language. Help us help you. Closing.
Check your types!
Expected value is not a string but a number. (This could be more clear in the description.)
Also, .match() returns an array. Correct application of parseFloat() to an array would involve .map(). This is why you are getting NaNs. See http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map.
I found you can use
console.dir()
on your result for this case or just test your function in browser's console.Because there's no such thing as 0.2 cent as price.
Hi, the thing is that if the input string is empty, or if there is no match between your regexp and the input string
str.match(/YOUR REGEXP/g)
is going to returnnull
instead of an array, so you can't executejoin("")
as a method ofnull
. I think that's all I can say :). Good LuckThe Set constructor stores unique values, and accepts an iterable (like an Array or a Set) as its one argument. The construction removes duplicate values determined via the
===
operator.The
...
Spread operator can spread an iterable (like a Set or an Array) into multiple arguments or array elements.A more verbose syntax for this solution might be:
More documentation if needed:
Your function fails when one of the arguments is null.
isFinite
returns true for null, even though it is obviously not a number.