From c435f648688cc718933f3ac832fc8a85d68b130c Mon Sep 17 00:00:00 2001 From: King Date: Mon, 12 Feb 2018 16:47:53 -0500 Subject: [PATCH] refactor snippet reducing the amount of lines --- snippets/permuteAll.md | 7 ++----- test/permuteAll/permuteAll.js | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/snippets/permuteAll.md b/snippets/permuteAll.md index d6555210b..63cde20da 100644 --- a/snippets/permuteAll.md +++ b/snippets/permuteAll.md @@ -7,11 +7,8 @@ const permuteAll = (input) => { const result = []; let inputState = input; - if (typeof input === 'string') { - inputState = input.split(''); - } else if (typeof input === 'number') { - inputState = (input).toString().split(''); - } + if (typeof input === 'string') inputState = input.split('') + if (typeof input === 'number') inputState = (input).toString().split(''); const permute = (arr, m = []) => { if (arr.length === 0) { diff --git a/test/permuteAll/permuteAll.js b/test/permuteAll/permuteAll.js index f005c1bd8..672c7a094 100644 --- a/test/permuteAll/permuteAll.js +++ b/test/permuteAll/permuteAll.js @@ -2,11 +2,8 @@ const permuteAll = (input) => { const result = []; let inputState = input; -if (typeof input === 'string') { -inputState = input.split(''); -} else if (typeof input === 'number') { -inputState = (input).toString().split(''); -} +if (typeof input === 'string') inputState = input.split('') +if (typeof input === 'number') inputState = (input).toString().split(''); const permute = (arr, m = []) => { if (arr.length === 0) {