File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 55 * @returns {boolean }
66 */
77function isPalindrome ( word ) {
8- return word . toString ( ) == reverseString ( word . toString ( ) ) ;
8+ return ! word ? "" : word . toString ( ) == word . toString ( ) . split ( "" ) . reverse ( ) . join ( "" ) ;
99}
1010module . exports = isPalindrome ;
Original file line number Diff line number Diff line change 1+ const isPalindrome = require ( "../project/js/functionality/isPalindrome.js" ) ;
2+
3+ it ( "always returns a boolean value" , function ( ) {
4+ expect ( typeof isPalindrome ( "123" ) ) . toBe ( "boolean" ) ;
5+ } ) ;
6+
7+ it ( "returns true if word is palindrome" , function ( ) {
8+ expect ( isPalindrome ( "mum" ) ) . toBe ( true ) ;
9+ } ) ;
10+
11+ it ( "returns false if word is not palindrome" , function ( ) {
12+ expect ( isPalindrome ( "muom" ) ) . toBe ( false ) ;
13+ } ) ;
14+
15+ it ( "returns true if word is palindrome also if the parameter is number" , function ( ) {
16+ expect ( isPalindrome ( 121 ) ) . toBe ( true ) ;
17+ } ) ;
18+
19+ it ( "returns false if word is not palindrome also if the parameter is number" , function ( ) {
20+ expect ( isPalindrome ( 123 ) ) . toBe ( false ) ;
21+ } ) ;
22+
23+ it ( "returns empty string if there is no parameter" , function ( ) {
24+ expect ( isPalindrome ( ) ) . toBe ( "" ) ;
25+ } ) ;
You can’t perform that action at this time.
0 commit comments