| Viewed 106 times

How I can Move Capital Letters to the Front in JavaScript?


I need a function that moves all capital letters to the front of a word.

1 Answer
Mohammad Qandeel
Answered
6

You can move capital letters to the front in JavaScript using this function

function capToFront(s) {
 let lowerCase = [...s].filter(l => l === l.toLowerCase())
 let upperCase = [...s].filter(l => l === l.toUpperCase())
 return [...upperCase,...lowerCase].join("")
}


Related Questions