-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathListing_7.10.js
More file actions
32 lines (26 loc) · 884 Bytes
/
Listing_7.10.js
File metadata and controls
32 lines (26 loc) · 884 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
30
31
32
// Reverses a string.
function reverse(string) {
return Array.from(string).reverse().join("");
}
// Defines a Phrase object.
function Phrase(content) {
this.content = content;
// Returns content processed for palindrome testing.
this.processedContent = function processedContent() {
return this.content.toLowerCase();
}
// Returns true if the phrase is a palindrome, false otherwise.
this.palindrome = function palindrome() {
return this.processedContent() === reverse(this.processedContent());
}
}
// Defines a TranslatedPhrase object.
function TranslatedPhrase(content, translation) {
this.content = content;
this.translation = translation;
// Returns translation processed for palindrome testing.
this.processedContent = function processedContent() {
return this.translation.toLowerCase();
}
}
TranslatedPhrase.prototype = new Phrase();