Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/capitalsFirst.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сделай split один раз и запиши в переменную

const lowerCaseW = str.split(' ').filter(word => word[0].match(/\b[a-z]/g));
return [...upperCaseW, ...lowerCaseW].join(' ');
}

module.exports = capitalsFirst;