From 3564e59684f820416281814109ce0c56fe21c445 Mon Sep 17 00:00:00 2001 From: Shota Gog Date: Mon, 18 Oct 2021 19:27:05 +0400 Subject: [PATCH] easy solution of stringConstruction I think the easiest and more readable solution of stringConstruction challenge looks like this: after splitting "b" string we map it and compare it to "a" string using the filter method. Then make flatten and save it in a variable. At last, just divide the length of this variable by the length of "a" string --- stringsConstruction/easy solution of stringConstruction | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 stringsConstruction/easy solution of stringConstruction diff --git a/stringsConstruction/easy solution of stringConstruction b/stringsConstruction/easy solution of stringConstruction new file mode 100644 index 00000000..fc4e56b2 --- /dev/null +++ b/stringsConstruction/easy solution of stringConstruction @@ -0,0 +1,2 @@ + let arr = b.split('').map( x => a.split('').filter(y => y === x)).flat(); + return arr.length / a.length // my solution;