jonas_bird-palindrome 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +5 -1
- package/package.json +1 -1
- package/test/test.js +5 -0
package/index.js
CHANGED
|
@@ -23,7 +23,11 @@ function Phrase(content) {
|
|
|
23
23
|
|
|
24
24
|
// Returns true if the phrase is a palindrome, false otherwise
|
|
25
25
|
this.palindrome = function palindrome() {
|
|
26
|
-
|
|
26
|
+
if (this.processedContent().length === 0) {
|
|
27
|
+
return false;
|
|
28
|
+
} else {
|
|
29
|
+
return this.processedContent() === this.processedContent().reverse();
|
|
30
|
+
}
|
|
27
31
|
};
|
|
28
32
|
|
|
29
33
|
this.louder = function () {
|
package/package.json
CHANGED
package/test/test.js
CHANGED
|
@@ -22,6 +22,11 @@ describe("Phrase", function () {
|
|
|
22
22
|
let punctuatedPalindrome = new Phrase("Madam, I'm Adam.");
|
|
23
23
|
assert(punctuatedPalindrome.palindrome());
|
|
24
24
|
});
|
|
25
|
+
|
|
26
|
+
it("should return false for an empty string", function () {
|
|
27
|
+
let emptyPalindrome = new Phrase("");
|
|
28
|
+
assert(!emptyPalindrome.palindrome());
|
|
29
|
+
});
|
|
25
30
|
});
|
|
26
31
|
|
|
27
32
|
describe("#letters", function () {
|