diff --git a/Text/03.Check if Palindrome.js b/Text/03.Check if Palindrome.js new file mode 100644 index 0000000..9481dc7 --- /dev/null +++ b/Text/03.Check if Palindrome.js @@ -0,0 +1,13 @@ +/* + Checks if the string entered by the user is a palindrome. + That is that it reads the same forwards as backwards like “racecar” +*/ +(function () { + var palindrome = function palindrome(integer) { + return integer === parseInt(integer.toString().split('').reverse().join('')); + }; +})(); + +// palindrome(1223221) => true +// palindrome(1222111) => false +// this case in javascript is very simple! diff --git a/readme.md b/readme.md index f951feb..ecf5737 100644 --- a/readme.md +++ b/readme.md @@ -79,7 +79,7 @@ Text **Count Vowels** - Enter a string and the program counts the number of vowels in the text. For added complexity have it report a sum of each vowel found. -**Check if Palindrome** - Checks if the string entered by the user is a palindrome. That is that it reads the same forwards as backwards like “racecar” +[**Check if Palindrome**](https://github.com/quitrk/LearningJS/blob/master/Text/03.%20Check%20if%20Palindrome.js) - Checks if the string entered by the user is a palindrome. That is that it reads the same forwards as backwards like “racecar” **Count Words in a String** - Counts the number of individual words in a string. For added complexity read these strings in from a text file and generate a summary. @@ -99,7 +99,7 @@ Text **Random Gift Suggestions** - Enter various gifts for certain people when you think of them. When its time to give them a gift (xmas, birthday, anniversary) it will randomly pick one. *Optional: Suggest places you can get it (link to Amazon page?).* -**Markdown to HTML Converter** - Converts Markdown formatted text into HTML files. Implement basic tags like `p`, `strong`, `em` etc. *Optional: Implement all tags from [Markdown Syntax Docs](http://daringfireball.net/projects/markdown/syntax).* +**Markdown to HTML Converter** - Converts Markdown formatted text into HTML files. Implement basic tags like `p`, `strong`, `em` etc. *Optional: Implement all tags from [Markdown Syntax Docs](http://daringfireball.net/projects/markdown/syntax).* **Regex Query Tool** - A tool that allows the user to enter a text string and then in a separate control enter a regex pattern. It will run the regular expression against the source text and return any matches or flag errors in the regular expression.