UNPKG

-tlecoeuv

Version:
33 lines (25 loc) 609 B
module.exports = Phrase; function reverse(string) { return Array.from(string).reverse().join(""); } // Defines a Phrase object. function Phrase(content) { this.content = content; this.processedContent = function processedContent() { return this.letters().toLowerCase(); } this.palindrome = function plaindrome() { return this.processedContent() === reverse(this.processedContent()); } this.letters = function letters() { return (this.content.match(/[a-z]/gi) || []).join(""); } } String.prototype.reverse = function() { return Array.from(this).reverse().join(""); }