We have to make a program that test a 5 digit number as a palindrome. I have no clue on how to do this. I was given advice that I'd need to use arrays, but for javascript I have no idea how to work with them. I read some stuff in a book and read some tutorials, but this is the best I can do:
Expand|Select|Wrap|Line Numbers
- var numa
- var pal = new Array(5)
- numa = window.prompt( "Please enter a five digit number number");
- num1 = parseInt ( numa );
- while (numa < 10000 || numa > 99999 )
- {
- window.alert ("The number is not 5 digits please enter a 5 digit number ");
- numa = window.prompt( "Please enter a five digit number number");
- }
- for (var i = 0; i < 5; ++i)
- {pal[ num1 ] = numa;
- }
- pal.test (compareIntegers );
- function compareIntegers(vaule1, vaule2, vaule4, vaule5)
- {
- if (vaule1 == vaule5 );
- {
- if (vaule2 == vaule4 )
- {
- doucment.writeln ( "The number is a palindrome")
- }
- }
- else
- document.writeln ("The number is not a palindrome")
- }
Thank you for your time and help.