-
Notifications
You must be signed in to change notification settings - Fork 0
/
16nov22SliceThis.js
21 lines (16 loc) · 1.27 KB
/
16nov22SliceThis.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Jaden Smith, the son of Will Smith, is the star of films such as The Karate Kid (2010) and After Earth (2013). Jaden is also known for some of his philosophy that he delivers via Twitter. When writing on Twitter, he is known for almost always capitalizing every word. For simplicity, you'll have to capitalize each word, check out how contractions are expected to be in the example below.
Your task is to convert strings to how they would be written by Jaden Smith. The strings are actual quotes from Jaden Smith, but they are not capitalized in the same way he originally typed them.
Example:
Not Jaden-Cased: "How can mirrors be real if our eyes aren't real"
Jaden-Cased: "How Can Mirrors Be Real If Our Eyes Aren't Real"
String.prototype.toJadenCase = function () {
// given prototype. Function has no params. Use this operator
//given is a stirng, spaces, multiple words, never empty, proper lowercase
//return same string with each word capitalized in the start
//Not Jaden-Cased: "How can mirrors be real if our eyes aren't real"
// Jaden-Cased: "How Can Mirrors Be Real If Our Eyes Aren't Real"
// split this, then map, then use toUpperCase method and slice that first word, then join
return this.split(' ')
.map(el=> el[0].toUpperCase() + el.slice(1))
.join(' ')
};