-
Notifications
You must be signed in to change notification settings - Fork 0
/
21-05-2022.js
42 lines (25 loc) · 1.45 KB
/
21-05-2022.js
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
29
30
31
32
33
34
35
36
37
38
39
40
41
/* 7 Kyu - Consecutive items
You are given a list of unique integers arr, and two integers a and b. Your task is to find out whether or not a and b appear consecutively in arr, and return a boolean value (True if a and b are consecutive, False otherwise).
It is guaranteed that a and b are both present in arr.
*/
//SOLUTION
function consecutive(arr, a, b) {
let value = false
for(i=0;i<arr.length-1;i++){
if ((arr[i] === a && arr[i+1] === b) || (arr[i] === b && arr[i+1] === a)){
value = true;
}
}
return value
}
/* 7 Kyu - Jaden Casing Strings
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"
*/
//SOLUTION
String.prototype.toJadenCase = function () {
return this.split(' ').map( x => x.slice(0,1).toUpperCase() + x.slice(1) ).join(' ');
};