22 lines
480 B
JavaScript
22 lines
480 B
JavaScript
module.exports = Phrase;
|
|
|
|
// Adds `reverse` to all strings.
|
|
String.prototype.reverse = function() {
|
|
return Array.from(this).reverse().join("");
|
|
}
|
|
|
|
function Phrase(content) {
|
|
this.content = content;
|
|
.
|
|
.
|
|
.
|
|
// Returns true if the phrase is a palindrome, false otherwise.
|
|
this.palindrome = function palindrome() {
|
|
if (this.processedContent()) {
|
|
return this.processedContent() === this.processedContent().reverse();
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
}
|