Forum Moderators: open
Another exapmle:
var a=100;
a=a.wrap(45, 65);
alert(a); //gives 58.
TNT Basic [tntbasic.com] has this function, all I have to do is create a new file and add one line of code, print wrap(100, 45, 65), and it gives me 58.
Not really, I want a function that 'wraps' a number between two numbers.
I still have no idea what that means. I've never heard this terminology used... wrapping a number? Never heard of it.
Here's your example:
var a=100;
a=a.wrap(45, 65);
alert(a); //gives 58.
So you have a number (100) that you call this 'wrap' method on with 2 other numbers (45 and 65). This returns 58? What is 58? Is it a random number? Is there some mathmatical formula to what wrap is supposed to do?
Here's another example of how it works:
a=9;
a=a.wrap(-3, 0);
So, since 9>0, we start at -3, here's the list (the output number is allowed to be -3, -2, -1, and 0), so we add one and keep looping through that list until we moved 9 places.
I've found this function very useful while using TNT Basic.