Forum : assignment probs
Brief description  about Online courses   join in Online courses
View Alok Ranjan Rai 's Profile

assignment probs

Dear sir,
i have taken assignment no 3, but i did not understand this line
(Reverse of a string and check whether it is palindrome or not)
Asked by Alok Ranjan Rai | Jan 31, 2011 |  Reply now
Replies (2)
View alok ranjan rai 's Profile
thanks sir
Jan 31, 2011
View teacher siliconindia 's Profile
Hi Alok,

Just input one string from user, just reverse it,
eg: if alok is a keyword, reverse of a string ll be 'kola'.

and check the initial string and output string are same, if it is same, then alert that its a palindrome. if not 'not a palindrome'

function for reverse of a string,

<script type="text/javascript">

var my_str="siliconindia"

var i=my_str.length;
i=i-1;

for (var x = i; x >=0; x--)
{
document.write(my_str.charAt(x));

}

</script>
Jan 31, 2011