So? Still solves problem, and still works. Just showing how it could be written in a short way. Code golf. I'm not advocating for this style in project code.
It still only accepts one parameter (function length is still 1) - nothing in the description of the task says we can't also have an optional parameter 😀
By the way, you missed the
seconds
parameter in your function definitions. Running them gives an error.__But where is var p declared? Only one line is not posible ;)
It would be:
Perfectly possible. There was no rule about not polluting the global namespace. The function works just fine
Or, if you don't want to pollute globals:
Ok, I executed it on node.js.
The latest solution change the contract of the function.
So? Still solves problem, and still works. Just showing how it could be written in a short way. Code golf. I'm not advocating for this style in project code.
It still only accepts one parameter (function length is still 1) - nothing in the description of the task says we can't also have an optional parameter 😀
yeah! It's cool, no problem! 😉