Interesting kata. Seems easy enough but it doesn't offer strict inputs and you have to figure out how to handle the edge cases. Feels like a real world problem
null does not have any methods, in particular it does not have a filter() method, this is why your code throws an error when called with null. this is consistent across all JavaScript implementations and has nothing to do with the environment. you have to add an explicit guard for null, since it is a valid input in this kata (which is not good practice, but that's besides the point)
Interesting kata. Seems easy enough but it doesn't offer strict inputs and you have to figure out how to handle the edge cases. Feels like a real world problem
Should have just given the formula for center of mass,
mass1position1 + mass2position2 ... / mass1 + mass2 ...
or at least a better hint
null
does not have any methods, in particular it does not have afilter()
method, this is why your code throws an error when called withnull
. this is consistent across all JavaScript implementations and has nothing to do with the environment. you have to add an explicit guard fornull
, since it is a valid input in this kata (which is not good practice, but that's besides the point)This comment is hidden because it contains spoiler information about the solution