can some explain this code

admin

Administrator
Staff member
could someone please explain this code to me step by step as i'm pretty new to this and need to understand!!

also I have a program with a.splice in it ......

return a.splice( parseInt(Math.random() * a.length), 1 );

but it wont work anyone any ideas as to what to change it to.

all help gratefully appreciated...



function checkNumber(number)
{
if(((number) < 10000) && ((number) > 0))
{
var numeral = createNumeral(number);
{
window.document.form.numeral.value = numeral;
}
}else{
alert('You have entered an invalid number!!');
}
}
function createNumeral(num)
{
var new_num = num
var thousands = Math.floor(new_num / 1000);
new_num -= thousands * 1000;
var hundreds = Math.floor(new_num / 100);
new_num -= hundreds * 100;
var tens = Math.floor(new_num / 10);
new_num -= tens * 10;
var ones = Math.floor(new_num / 1);
{
var array = new Array(thousands,hundreds,tens,ones);
return makeNumeral(array);
}
}
function makeNumeral(place_values)
{
var numeral = "";
numeral += thousands_value[place_values[0]];
numeral += hundreds_value[place_values[1]];
numeral += tens_value[place_values[2]];
numeral += ones_value[place_values[3]];
return numeral;


cheers
Graemo
 
Back
Top