I am moving on to Basic Algorithm Scripting and I understand what is needed

to complete the basic pass of the exercise, but I want I really would like to know

is what is considered best practice in of algorithm writing in the real world.

Take for example the ‘Factorialize a Number’ algorithm…

This would satisfy the exercise requirements, but it could break.

function factorial(num) {

var factorial = num;

while (–num > 0) {

factorial *= num;

}

return factorial;

}

I would like to know what other considerations should I know in order to make

a function that doesn’t break. Some of the things I came up with are:

- What if function argument is non-numeric? Should it handle strings? objects?
- What if the argument is floating-point, or a negative value?
- Should it check for bounds? what are the maximum safe values

If you have other function definition considerations I would like to hear them,

Thank you for your reply.