Personally, I’m not against the use of FF, but in order to have a consistent meaning, a word must always have the same abbreviation, don’t you agree? That’s my thoughts on it, anyway–kind of like the same reason why we have standardized HTML.
Let’s not get off topic, though. I don’t think Ultimater would appreciate that.
For me personally, this is the most useful prototype function in this thread.
Often I will want to know the position of... say the third occurance of a string within another. This is similar to indexOf() but instead of just getting the first occurance you can specifiy a second argument which will be the nth occurance.
Specifying a negative value for n will count from the back rather than the front.
Specifying no value for n will presume the value 1 for n.
Specifying a string or decimal or zero for n will return -1.
If the string is not found at the nth occurance will also return -1.
Yep its fixed. I also made a fix to String.dex(), didnt realise till i saw yours that indexOf() took 2 arguments. My version drains less resources from the computer as it only calls indexOf() as many times as it has to.
For Those who dont know what factorial is it is the number of sequences that can exist with a set of items, derived by multiplying the number of items by the next lowest number until 1 is reached. For example, three items have six sequences (3x2x1=6): 123, 132, 231, 213, 312 and 321. Also note that zero factorial (in Maths noted by 0!) is equal to 1.
I guess the easiest way to beat that script for efficiency would be to simply store the factorials for all numbers up to 170 in a hard-coded array from the very beginning and return the appropriate NaN or Infinity otherwise. You'd never spend any time computing values, or checking for their existence in the array, since you already have them all.
Of course, that is a pretty lame approach...
Kids, kids... you tried your best, and you failed miserably; the lesson is: never try.