let input = "supercalifragilisticexpialidocious";
console.log(input);
/*
add all same ending letters to a list
check every item and remove it if its not a palendrome
*/
let palendrome = 0;
let palendromes = [];
for (let i = 0; i < input.length; i++) {
palendrome = input.substr(i, input.lastIndexOf(input.charAt(i))-i+1);
if (palendrome.length > 1 && palendrome == palendrome.split("").reverse().join("")) {
console.log(palendrome);
palendromes.push(palendrome);
}
}
function check(palen) {
if (palen.length > 1 && palen == palen.split("").reverse().join("")) {
console.log(palen);
palendromes.push(palen);
} else {
let palen2 = palen.substr(palen.charAt(0), palen.substr(0, palen.length-1).lastIndexOf(palen.charAt(0)));
if (palen2.charAt(0) == palen2.charAt(palen2.length)){
check(palen2);
}
}
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.