diff --git a/src/is_palindrome.js b/src/is_palindrome.js index 2b6ba81..043a215 100644 --- a/src/is_palindrome.js +++ b/src/is_palindrome.js @@ -1,6 +1,11 @@ const isPalindrome = function (text) { +let textReversed = text.reverse(); -}; +if(textReversed == text){ + return true; +} else { + return false; +}}; module.exports = isPalindrome; diff --git a/src/is_pangram.js b/src/is_pangram.js index 971e25c..3d5de8d 100644 --- a/src/is_pangram.js +++ b/src/is_pangram.js @@ -1,5 +1,20 @@ const isPangram = function(text) { +// change input text to lower case + +text.toLowerCase() + +//all alphabet letters +let letters = "abcdefghijklmnopqrstuvwxyz".split(''); -}; +//check if all letters are included +for(let letter of letters){ + if(!text.includes(letter)){ + return false + } +} + +return true + +}; module.exports = isPangram; diff --git a/test/is_pangram.test.js b/test/is_pangram.test.js index 85670a4..1083c14 100644 --- a/test/is_pangram.test.js +++ b/test/is_pangram.test.js @@ -9,54 +9,53 @@ describe('isPangram()', () => { // Arrange const text = 'the quick brown fox jumps over the lazy dog'; - // Act - - // Assert + // Act, Assert + expect(isPangram(text)).toBeTruthy(); }); test('works with "abcdefghijklmnopqrstuvwxyz"', () => { // Arrange + const text = "abcdefghijklmnopqrstuvwxyz"; - // Act - - // Assert + // Act, Assert + expect(isPangram(text)).toBeTruthy(); }); test("missing character 'x'", () => { // Arrange + const text = "abcdefghijklmnopqrstuvwyz"; - // Act - - // Assert + // Act, Assert + expect(isPangram(text)).toBeFalsy(); }); test('empty sentence', () => { // Arrange + const text = ""; - // Act - - // Assert - + // Act, Assert + expect(isPangram(text)).toBeFalsy(); + }); test('pangram with underscores instead of spaces works', () => { - // Arrange - - // Act + // Arrrange + const text = 'the quick_brown fox jumps over the lazy_dog'; - // Assert + // Act, Assert + expect(isPangram(text)).toBeTruthy(); }); test('pangram with numbers', () => { - // Arrange - - // Act - - // Assert + // Arrrange + const text = 'the 1 quick brown fox jumps 2 over the lazy dog'; + // Act, Assert + expect(isPangram(text)).toBeTruthy(); + }); // Write your own test case