diff --git a/chapter01/1.2 - Check Perm/checkPermute.js b/chapter01/1.2 - Check Perm/checkPermute.js index 0cb0931..d3f19a7 100644 --- a/chapter01/1.2 - Check Perm/checkPermute.js +++ b/chapter01/1.2 - Check Perm/checkPermute.js @@ -16,4 +16,19 @@ console.log(checkPermute('aba', 'aab'), true); console.log(checkPermute('aba', 'aaba'), false); -console.log(checkPermute('aba', 'aa'), false); \ No newline at end of file +console.log(checkPermute('aba', 'aa'), false); + +//Another solution + +function permutation(str1, str2) { + if (str1.length !== str2.length) { + return false; + } + + for (var i = 0; i < str1.length; i++) { + if (!str2.includes(str1.charAt(i))) { + return false; + } + }; + return true; +}