forked from delventhalz/paleo.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
03.String.js
39 lines (26 loc) · 1.14 KB
/
03.String.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
/* * * * * * * * * * * * * * * * * * * * * *
* CAVEMAN JS PT 3: STRING.PROTOTYPE *
* * * * * * * * * * * * * * * * * * * * * */
// Primitive values can get in on the method madness too!
/** Object.keys **/
// A little warmup before we get to the actual `String.prototype`, this
// function takes an object and returns an array of it's key names. Note
// it's not on the prototype! In the wild you'd write: `Object.keys(obj)`.
var keys = function(object) {
};
/** String.prototype.slice **/
// This useful method copies a piece of a string from a start index
// (inclusive) and an end index (non-inclusive). `Array.prototype`
// has a similar method. Make your `slice` to work for both.
var slice = function(stringOrArray, start, end) {
};
/** String.prototype.trim **/
// A handy little method for processing text. Returns the input string
// with all white space removed from the beginning and the end.
var trim = function(string) {
};
/** String.prototype.replace **/
// Searches for a target sub-string and replaces it.
// Note that only the first instance is replaced.
var replace = function(string, target, replacement) {
};