-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
143 lines (106 loc) · 4.82 KB
/
test.html
File metadata and controls
143 lines (106 loc) · 4.82 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<script src="src/strings.js"></script>
<script>
var test = "Hello world!";
var testNum = "12,345,679.312";
var testTags = "<span style='color:red'><i>Hello</i> <b>world</b>!</span>";
var testSentence = "The quick brown fox jumps over the lazy dog";
var testTitle = "new rules grant F.B.I., DEA & CIA access to 'raw' NSA surveillance data";
var a = strings.count(test, "l"); // 3
console.log(a);
var b0 = strings.endsWith(test, "D!"); // false
var b1 = strings.endsWith(test, "D!", false); // false
var b2 = strings.endsWith(test, "D!", true); // true
console.log(b0, b1, b2);
var c0 = strings.includes("Hello world", "WO"); // false
var c1 = strings.includes("Hello world", "WO", true); // true
var c2 = strings.includes("Hello world", "WO", false); // false
console.log(c0, c1, c2);
var d0 = strings.isAllCaps("YOOOO"); // true
var d1 = strings.isAllCaps("YO!"); // true
var d2 = strings.isAllCaps("YoO!"); // false
console.log(d0, d1, d2);
var e0 = strings.isAllDigits(testNum); // false;
var e1 = strings.isAllDigits(strings.removeAll(testNum, ",")); // false
var e2 = strings.isAllDigits(strings.removeAll(testNum, ",").replace(".", "")); // true
console.log(e0, e1, e2);
var f0 = strings.isAllLower(test); // false
var f1 = strings.isAllLower(test.toLowerCase() + "3"); // true
console.log(f0, f1);
var g = strings.keepAll(test, "l"); // "lll"
console.log(g);
var ga = strings.keepEnd(test, 3); // "ld!"
console.log(ga);
var h0 = strings.keepOne(test, "l"); // "l"
var h1 = strings.keepOne(test, "z"); // ""
console.log(h0, h1);
var i = strings.keepStart(test, 3); // "Hel"
console.log(i);
var j = strings.numberCommas(1234123.234); // "1,234,123.234"
console.log(j);
var k0 = strings.numberDecimals(1234123.2134, 2); // "1234123.21"
var k1 = strings.numberDecimals(1234123, 2); // "1234123.00"
console.log(k0, k1);
var l = strings.numberLakhs(1345122345.235); // "1,34,51,22,345.235"
console.log(l);
var m0 = strings.numberPrependZeros(1234, 4); // "1234"
var m1 = strings.numberPrependZeros(123, 4); // "0123"
var m2 = strings.numberPrependZeros(12345, 4); // "12345"
var m3 = strings.numberPrependZeros(1, 4); // "0001"
var m4 = strings.numberPrependZeros("", 4); // "0000"
var m5 = strings.numberPrependZeros("red", 4); // "0red"
console.log(m0, m1, m2, m3, m4, m5);
var n0 = strings.removeAll("Hello Jill how are you lady?", "l"); // "Heo Ji how are you ady?"
var n1 = strings.removeAll("Hello Jill how are you lady?", "ll"); // "Heo Ji how are you lady?"
console.log(n0, n1);
var o = strings.removeDigits(testNum); // ",,."
console.log(o);
var p = strings.removeFirst(test, "l"); // "Helo world!"
console.log(p);
var q = strings.removeLast(test, "l"); // "Hello word!"
console.log(q);
var r = strings.removeSymbols(test); // "Hello world"
console.log(r);
var s0 = strings.removeTags(testTags); // "Hello world!"
var s1 = strings.removeTags(testTags, ["i"]); // <i>Hello</i> world!
console.log(s0, s1);
var t = strings.replaceAll(test, "l", "z"); // "Hezzo worzd!"
console.log(t);
var ta = strings.replaceAt(test, 6, "Jonny"); // Hello Jonny!
console.log(ta);
var u = strings.replaceFirst(test, "l", "z"); // "Hezlo world!"
console.log(u);
var v = strings.replaceLast(test, "l", "z"); // "Hello worzd!"
console.log(v);
var w = strings.reverseCharacters(test); // "!dlrow olleH"
console.log(w);
var x = strings.reverseWords(test); // "world! Hello"
console.log(x);
var y = strings.shuffleCharacters(test); // e.g. "!oloHw elrld"
console.log(y);
var z = strings.shuffleCharactersInWords(test); // e.g. "oeHll !lrwdo"
console.log(z);
var aa = strings.shuffleWords(testSentence); // e.g. "over The lazy the quick fox jumps dog brown"
console.log(aa);
var ab0 = strings.startsWith("Hello world", "he"); // false
var ab1 = strings.startsWith("Hello world", "he", true); // true
var ab2 = strings.startsWith("Hello world", "he", false); // false
console.log(ab0, ab1, ab2);
var ac = strings.toCamelCase(test); // "helloWorld"
console.log(ac);
var ad = strings.toSentenceCase(testTitle); // "New rules grant F.B.I., DEA & CIA access to raw NSA surveillance data"
console.log(ad);
var ae = strings.toSlugCase(test); // "hello-world"
console.log(ae);
var af = strings.toSnakeCase(test); // "hello_world"
console.log(af);
var ag = strings.toStartCase(test); // "Hello World!"
console.log(ag);
var ah0 = strings.toTitleCase("the quick brown fox jumps over the lazy dog"); // "The Quick Brown Fox Jumps Over the Lazy Dog"
var ah1 = strings.toTitleCase("javascript: a beginner's guide to the language of the web"); // "Javascript: A Beginner's Guide to the Language of the Web"
var ah2 = strings.toTitleCase("james comey to remain on as FBI director"); // "James Comey to Remain on as FBI Director"
var ah3 = strings.toTitleCase(testTitle); // "New Rules Grant F.B.I., DEA & CIA Access to Raw NSA Surveillance Data"
console.log(ah0);
console.log(ah1);
console.log(ah2);
console.log(ah3);
</script>