-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstring concepts.js
47 lines (46 loc) · 1.22 KB
/
string concepts.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
42
43
44
45
46
47
/**
* Respond with the correct character, given the line of the
* poem, if this were said at the front door.
*
* @param {string} line
* @returns {string}
*/
export function frontDoorResponse(line) {
var trimLine=line.trim();
return trimLine[0];
}
/**
* Format the password for the front-door, given the response
* letters.
*
* @param {string} word the letters you responded with before
* @returns {string} the front door password
*/
export function frontDoorPassword(word) {
var firstLetter=word[0];
var remLetters=word.slice(1,);
return firstLetter.toUpperCase() + remLetters.toLowerCase();
}
/**
* Respond with the correct character, given the line of the
* poem, if this were said at the back door.
*
* @param {string} line
* @returns {string}
*/
export function backDoorResponse(line) {
var trimLine=line.trim();
return trimLine.slice(-1);
}
/**
* Format the password for the back door, given the response
* letters.
*
* @param {string} word the letters you responded with before
* @returns {string} the back door password
*/
export function backDoorPassword(word) {
var firstLetter=word[0];
var remLetters= word.slice(1,);
return firstLetter.toUpperCase() + remLetters.toLowerCase() + ", please";
}