html
html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<!--
Update: whoops had mixed double & single quotes; now it's fixed
minor code changes
version: v10.1.2018
-->
<!--
Freecodecamp challenge
https://www.freecodecamp.org/challenges/check-for-palindromes
"""
A palindrome is a word or sentence that's spelled the same way both forward and backward, ignoring punctuation, case, and spacing.
Note
You'll need to remove all non-alphanumeric characters (punctuation, spaces and symbols) and turn everything lower case in order to check for palindromes. """
-->
<!--
Todo: add an input box, move the explanation to about section
beautify & improve aesthetics
try to provide some additional information like length before & after transformation without complicating the code further
-->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Palindrom String</title>
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
body {
text-align: center;
font-size: 108%;
}
p{
margin: 0.4rem;
}
h1{
text-transform: capitalize;
color: crimson;
}
Enter to Rename, Shift+Enter to Preview
js
js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*
Author: Lord Krishna
Date: 10 Jan 2018
Version: v10.1.2018
My 1st Public code of New Year 2018!
*/
'use strict';
const al = alert;
//const cl = console.log;
this.addEventListener('DOMContentLoaded', main)
function main(){
al("Test if a string is a palindrome.\n removes punctuation & whitespace characters\n so 'so on_+' becomes 'soon'")
var input = prompt("enter some word to test if it's a palindrome", 's'); //default input
function palin(str){
var newStr = str.replace(/[\W_]/g, '').toLowerCase();
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run