Monday, June 8, 2020

String Palindrome in jQuery

I wrote this program to check if the given string is a string palindrome or not using jQuery.

I am currently accepting programming work inventory system, enrollment system, accounting system, payroll system, information system, website design and development using WordPress, IT projects, school and application development, programming projects, thesis, and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.My mobile number here in the Philippines is 09173084360. My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.


Here in Bacolod City, Negros Occidental I also accepting computer repair, web development using WordPress, Computer Networking, and Arduino Project development at a very affordable price. My personal website is http://www.jakerpomperada.com


My programming website is http://www.jakerpomperada.blogspot.comI am also a book author you can purchase my books on computer programming and information technology in the following links below.https://www.unlimitedbooksph.com/


Program Listing

<html>
<head>
<title>Palindrome String in jQuery</title>
</head>
<script type="text/javascript" src="jquery-3.2.1.min.js">
</script>
<body>
<script type="text/javascript">

function palindrome_check(str) {
var re = /[^A-Za-z0-9]/g;
str = str.toLowerCase().replace(re,'');
return str == str.split('').reverse().join('') ? true : false;
}

$(document).ready(function() { 
var str_given1 = "night";
var str_given2 = "radar";
var str_display1;
var str_display2;
document.write("<h2>Palindrome in jQuery</h2>");
document.write("<h2>Text Number One    : " ,str_given1,"</h2>");
document.write("<h2>Text Number Two    : " ,str_given2,"</h2>");

str_check1 = palindrome_check(str_given1);
str_check2 = palindrome_check(str_given2);

if  (str_check1 == true) {
str_display1 = "<h2>The string " +str_given1.toUpperCase()+" is Palindrome.</h2>";
} else {
str_display1 = "<h2>The string " +str_given1.toUpperCase()+" is Not Palindrome.</h2<";
}

if  (str_check2 == true) {
str_display2 = "<h2>The string " +str_given2.toUpperCase()+" is Palindrome.</h2>";
} else {
str_display2 = "<h2>The string " +str_given2.toUpperCase()+" is Not Palindrome.</h2<";
}
document.write(str_display1);
document.write(str_display2);
});
</script>
</body>
</html>

No comments:

Post a Comment