SOLVED & EXPLAINED | Jaden Casing Strings JavaScript | Data Structure & Algorithm

Опубликовано: 09 Август 2023
на канале: Geekelo - Female Tech Enthusiast
153
5

Question:

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"

Connect & reach out:
Join FREE Membership Community - https://tinyurl.com/geekspecials
Connect on LinkedIn -   / eloghene-otiede  

GUIDE:
To access the value and manipulate it using the `String.prototype.toJadenCase` function, you would need to define the function and use the `this` keyword to refer to the string instance on which the function is called. Here's how you can do it:

1. We define the `toJadenCase` function on the `String.prototype`. This makes the function available on all string instances.
2. Inside the function, we split the string into an array of words using the `split` method with a space delimiter.
3. We use the `map` method to iterate over each word in the array and capitalize the first letter of each word using `charAt(0).toUpperCase()`.
4. Finally, we use the `join` method to concatenate the words back together with spaces and return the Jaden Case string.

After defining the `toJadenCase` function on the `String.prototype`, you can call it on any string instance to convert the string to Jaden Case format. In the example, we call `toJadenCase` on the `sentence` string and store the result in the `jadenCaseSentence` variable. The output will be `"How Can Mirrors Be Real If Our Eyes Aren't Real"`.


На этой странице сайта вы можете посмотреть видео онлайн SOLVED & EXPLAINED | Jaden Casing Strings JavaScript | Data Structure & Algorithm длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Geekelo - Female Tech Enthusiast 09 Август 2023, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 153 раз и оно понравилось 5 зрителям. Приятного просмотра!