-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpalindrome.js
More file actions
29 lines (24 loc) · 778 Bytes
/
palindrome.js
File metadata and controls
29 lines (24 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Reverses a string.
String.prototype.reverse = function reverse() {
return Array.from(this).reverse().join("");
}
// Defines a Phrase object.
function Phrase(content) {
this.content = content;
// Process contnt for palindrome testing.
this.processor = function processor(string) {
return string.toLowerCase();
}
// Returns content processed for palindrome testing.
this.processedContent = function processedContent() {
return this.processor(this.content);
}
// Returns true for a palindrome, false otherwise.
this.palindrome = function palindrome() {
return this.processedContent() === this.processedContent().reverse();
}
// Returns the phrase LOUDER.
this.louder = function louder() {
return this.content.toUpperCase();
}
}