From b1165bea5e5b40d3a585fcf36e9656a1c8acb75b Mon Sep 17 00:00:00 2001 From: Dmitriymush Date: Wed, 2 Oct 2019 21:58:08 +0300 Subject: [PATCH 1/2] solution --- src/capitalsFirst.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/capitalsFirst.js b/src/capitalsFirst.js index 3fa9016..26c1f55 100644 --- a/src/capitalsFirst.js +++ b/src/capitalsFirst.js @@ -18,7 +18,8 @@ * @returns {string} - string with uppercase words in front */ function capitalsFirst(str) { - // write code here + const upperCaseW = str.split(' ').filter(word => word[0].match(/\b[A-Z]/g)); + const lowerCaseW = str.split(' ').filter(word => word[0].match(/\b[a-z]/g)); + return [...upperCaseW, ...lowerCaseW].join(' '); } - module.exports = capitalsFirst; From 569b6403fda959041586247989877ab4bcedd898 Mon Sep 17 00:00:00 2001 From: Dmitriymush Date: Thu, 3 Oct 2019 23:43:12 +0300 Subject: [PATCH 2/2] fixed --- src/capitalsFirst.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/capitalsFirst.js b/src/capitalsFirst.js index 26c1f55..e1203cd 100644 --- a/src/capitalsFirst.js +++ b/src/capitalsFirst.js @@ -18,8 +18,9 @@ * @returns {string} - string with uppercase words in front */ function capitalsFirst(str) { - const upperCaseW = str.split(' ').filter(word => word[0].match(/\b[A-Z]/g)); - const lowerCaseW = str.split(' ').filter(word => word[0].match(/\b[a-z]/g)); + const strPart = str.split(' '); + const upperCaseW = strPart.filter(word => word[0].match(/\b[A-Z]/g)); + const lowerCaseW = strPart.filter(word => word[0].match(/\b[a-z]/g)); return [...upperCaseW, ...lowerCaseW].join(' '); } module.exports = capitalsFirst;