-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript13.js
More file actions
29 lines (20 loc) · 896 Bytes
/
Copy pathscript13.js
File metadata and controls
29 lines (20 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Complete the solution so that the function will break up camel casing, using a space between words.
// Example
// "camelCasing" => "camel Casing"
// "identifier" => "identifier"
// "" => ""
// split str into arr
// loop through arr with map
// check for uppercase letter
// conditionally check if uppercase letter is equal to that letter
// if so, add a space + letter
// otherwise return letter
// join arr back to string
const breakCamelCase = str =>{
return str.split("").map(letter => letter ===letter.toUpperCase()? " " + letter : letter).join("");
}
console.log(breakCamelCase("camelCasing"))
console.log(breakCamelCase("identifier"))
console.log(breakCamelCase(""))
// IndifferentGhost
// `.at()` in most cases does the same as bracket notation for arrays, where it does well is including negative values `arr.at(-1)` is the same as `arr[arr.length -1]`.