Palindrome Checker by muazzam | JavaScriptSource

Palindrome Checker by muazzam

muazzam Feb 9, 2016

Abstract

Check if the word you choose is spelled the same backwards and forwards.

Description

check if the word you choose is spelt the same backwards and forwrds....a word that can be spelt backwards and forwards the same is called a palindrome

Code Snippet

var word=prompt("Give a word","");
			
			
function pal(){
	if(word===word.split('').reverse().join(''))
	{
		document.write("hello this is a palindrome"+"<br>"+word.split('').reverse().join('') +" is the same as "+word);
	}
	else
	{
		document.write("Error 504(Not a palindrome)"+"..."+"hello this is not a palindrome"+"<br>"+word.split('').reverse().join('') +" is not the same as "+word);
	}
		
}
pal();

Leave a Response

(0 comments)