From cc9e86c03967efe778c60f9145812ca83c42b15a Mon Sep 17 00:00:00 2001 From: Mary Date: Tue, 11 Dec 2018 14:35:20 -0500 Subject: [PATCH] Update palinPerm.js --- chapter01/1.4 - PalinPerm/palinPerm.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/chapter01/1.4 - PalinPerm/palinPerm.js b/chapter01/1.4 - PalinPerm/palinPerm.js index ca46496..ecf66c5 100644 --- a/chapter01/1.4 - PalinPerm/palinPerm.js +++ b/chapter01/1.4 - PalinPerm/palinPerm.js @@ -31,4 +31,22 @@ var palinPerm = function(string) { // TESTS console.log(palinPerm('Tact Coa'), 'true'); -console.log(palinPerm('Tact boa'), 'false'); \ No newline at end of file +console.log(palinPerm('Tact boa'), 'false'); + +//Another solution + +function palindrom(string) { + var test = []; + var arr = string.split(''); + for (char of arr) { + if (char !== ' ') { + test.push(char.toLowerCase()); + } + } + if (test.join('') === test.reverse().join('')) { + return true; + } else { + return false; + } +} +