-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f0d5d57
commit 08ef69b
Showing
3 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Document</title> | ||
<link rel="stylesheet" href="style.css" /> | ||
</head> | ||
<body> | ||
<h2>Javascript Palindrome Checking Function</h2> | ||
<script src="script.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
function palindrome(myString) { | ||
/* remove special characters, spaces and make lowercase*/ | ||
var removeChar = myString.replace(/[^A-Z0-9]/gi, "").toLowerCase(); | ||
|
||
/* reverse removeChar for comparison*/ | ||
var checkPalindrome = removeChar.split("").reverse().join(""); | ||
|
||
/* Check to see if myString is a Palindrome*/ | ||
if (removeChar === checkPalindrome) { | ||
document.write("<div>" + myString + " is a Palindrome <div>"); | ||
} else { | ||
document.write("<div>" + myString + " is not a Palindrome </div>"); | ||
} | ||
} | ||
palindrome('"Oh who was it I saw, oh who?"'); | ||
palindrome('"Madam"'); | ||
palindrome('"Star Wars"'); | ||
palindrome('"2,3,4,3,2"'); | ||
palindrome('"7,10,7,8,9"'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
div { | ||
margin-top: 20px; | ||
} |