Make a function ‘sum’ that returns a sum of two values.
this function should be called as these examples:
console.log(sum(5, 3)); // returns 8
console.log(sum(5)(3)); // returns 8
Is also an immediate red flag that should tell you "NEVER WORK HERE" - no sane person would ever write a function with such obviously differing return values depending a bit on the number of arguments. Holy hell that would make life working with their codebase a pain in the ass, and JavaScript is already a big enough pain in the ass without artificially making it worse.
Tinkerer, crossfiter and a music junky... Maker of: http://musicmeal.io / https://twitter.com/AudioPlayer3 & https://twitter.com/BirdOfKnowledge & https://twitter.com/JanusWorkspace
IMO they just wanted to see if anyone knows what currying is. This being said there are two things
I haven't seen anyone use currying in my past 6 years as a developer, neither at work or at code examples of finished products. I have recently seen it as part of articles, to which there are links in my article.
If they are actually using it - WHY? being able to support handling arguments that way is weird and is a step away from also handling sum([5,3]), or sum ([5,[[3]]]) or something weirder, that I can't think of right now.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Oh btw the test:
Is also an immediate red flag that should tell you "NEVER WORK HERE" - no sane person would ever write a function with such obviously differing return values depending a bit on the number of arguments. Holy hell that would make life working with their codebase a pain in the ass, and JavaScript is already a big enough pain in the ass without artificially making it worse.
IMO they just wanted to see if anyone knows what currying is. This being said there are two things