This is just a thought experiment in me trying to learn javascript and a idea called duck typing.
function calc(a,b,c) {
return (a+b)*c;
}
var example1 = calc(1,2,3);
var example2 = calc([1,1,3],[2,2,3],3);
var example3 = calc ('ape ', 'and cat, ', 3)
console.log(example1, example2, example3);
How can I make the return values appear like so:
9
[1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6]
ape and cat, ape and cat, ape and cat,
Currently they will print out as:
9
NaN
NaN
are there helpers in lo-dash?
Here's the sample code: http://repl.it/4zp/2
This should work with strings, numbers and arrays. Additionally, I did toy around with the idea of converting arrays to string and back again if we want to implicitly use the + operator in a similar way to strings.