File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616h1 {
1717 font-size : 2.5rem ;
1818 font-family : cursive;
19- color : rgba ( 0 , 119 , 40 , 0.452 ) ;
19+ color : seagreen ;
2020 margin-bottom : 20px ;
2121}
2222
3737 top : 50% ;
3838 left : 50% ;
3939 transform : translate (-50% , -50% );
40- -webkit-text-stroke : 1px rgb (11 , 12 , 12 );
41-
4240}
4341
4442# input {
4543 padding : 10px ;
4644 width : 450px ;
4745 font-size : 0.8rem ;
4846}
49-
47+ .button {
48+ top : 50% ;
49+ left : 50% ;
50+ width : 75px ;
51+ transform : translate (-50% , -50% );
52+ -ms-transform : translate (-50% , -50% );
53+ background-color : # f1f1f1 ;
54+ color : black;
55+ font-size : 16px ;
56+ cursor : pointer;
57+ border-radius : 5px ;
58+ text-align : center;
59+ }
5060button : hover {
51- cursor : pointer;
52- background-color : white;
53- font-weight : medium;
54- box-shadow : 0 0 10px rgb (169 , 205 , 235 );
55- color : # 137570 ;
61+ background-color : black;
62+ color : white;
5663}
Original file line number Diff line number Diff line change 11<!DOCTYPE html>
22< html >
33 < head >
4- < link rel ="stylesheet " href ="palindrome.css ">
4+ < link rel ="stylesheet " href ="palindrome.css " / >
55 </ head >
66 < body >
77 < div class ="image "> </ div >
88 < div class ="text ">
99 < h1 > PALINDROME CHECKER</ h1 >
1010 < form >
11- < input type ="text " id ="input " name ="input " oninput ="palindrome_check() " placeholder ="Enter a string " autocomplete ="off ">
11+ < input
12+ type ="text "
13+ id ="input "
14+ name ="input "
15+ placeholder ="Enter a string "
16+ autocomplete ="off "
17+ />
1218 </ form >
19+ < button type ="button " class ="button " onclick ="palindrome_check() ">
20+ Check
21+ </ button >
22+ < button type ="button " class ="button " onclick ="reset() "> Reset</ button >
1323 < p id ="prog "> </ p >
1424 < script src ="palindrome.js "> </ script >
1525 </ div >
Original file line number Diff line number Diff line change 1- function palindrome_check ( ) {
2- var ishtra = document . getElementById ( "input" ) . value ;
3- var reg = / [ \W _ ] / g;
4- var smallstring = ishtra . toLowerCase ( ) . replace ( reg , "" ) ;
5- var reversed = smallstring . split ( "" ) . reverse ( ) . join ( "" ) ;
6- if ( reversed === smallstring ) {
7- document . getElementById ( "prog" ) . innerHTML = `<b>"${ ishtra } "</b> is a palindrome!.` ;
1+ function palindrome_check ( ) {
2+ var str1 = document . getElementById ( "input" ) . value ;
3+ var str = str1 . replace ( / \s / g, "" ) ;
4+ if ( isPalindrome ( str ) === true )
5+ document . getElementById ( "prog" ) . innerHTML = `<b>"${ str } "</b> is a palindrome!.` ;
6+ else
7+ document . getElementById ( "prog" ) . innerHTML = `<b>"${ str } "</b> is not a palindrome!.` ;
8+ }
9+ function isPalindrome ( str1 ) {
10+ str = str1 . toLowerCase ( ) ;
11+ for ( let i = 0 ; i < Math . floor ( str . length / 2 ) ; i ++ )
12+ {
13+ var char1 = str [ i ] , char2 = str [ str . length - 1 - i ] ;
14+ if ( char1 !== char2 )
15+ {
16+ return false ;
17+ }
18+
819 }
9- else {
10- document . getElementById ( "prog" ) . innerHTML = `<b>"${ ishtra } "</b> is not a palindrome!.` ;
11- }
20+ return true ;
21+ }
22+ function reset ( ) {
23+ document . getElementById ( "input" ) . value = "" ;
24+ document . getElementById ( "prog" ) . innerHTML = "" ;
1225}
You can’t perform that action at this time.
0 commit comments