Skip to main content

Posts

Showing posts from October, 2021

Write a script/program to check a string is palindrome or not.

Script/program to check a string is palindrome or not: function testFun(txt){     var newTxt = txt.split("");     var myOP = "";       for(let i = newTxt.length-1; i>=0; i--){       console.log(newTxt[i]);         myOP += newTxt[i];     } // console.log(myOP);     if(txt === myOP){         console.log(txt + " is Palindrome");     }else{         console.log(txt + " is not Palindrome");     } } var str= "RAJU"; testFun(str); //First call of test function var str2= "MADAM"; testFun(str2);  //Second call of test function Output: Raju is not Palindrome. //First call of test function MADAM is Palindrome.//Second call of test function