Please solve my issue, I am going to check a list of strings as palindrome, if any of the string from the array is palindrome then it should display a result true, the result should be in string value not in Boolean value. I had tried so many times but it is not displaying the result; See my code below:-
function checkPry()
{
var status = new Array();
var wordList1 = document.getElementById("tk").value;
var wordArray = new Array();
wordArray = wordList1.split(" ");
var alength = wordArray.length;
for(var i=0; i <= alength; i++)
{
var str = wordArray[i];
var chrlength = str.length;
var lw = chrlength - 1;
var chk = "";
for(j=0; j<=chrlength; j++)
{
if(str.charAt(j) != str.charAt((lw - j)))
{
chk = "false";
break;
}
else
{
chk = "true";
}
}
if (chk == "true")
{
status[i] = "true";
}
else if (chk == "false")
{
status[i] = "false"
}
}
var displayStr = status.toString();
document.getElementById("show").innerHTML = displayStr;
}
like If I am giving the input value as [dalad radar jaijai rexem]
then it should be give result as [true,true,false,false]
, Please help me in that; you can also check the fiddle below:--
Thanks!