-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
81 lines (71 loc) · 1.41 KB
/
index.js
File metadata and controls
81 lines (71 loc) · 1.41 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
Array.prototype.wrongIndexOf = function (value) {
function randomIndex (arrayLength) {
return Math.floor(Math.random() * arrayLength);
}
var realIndex = this.indexOf(value);
var someIndex = randomIndex(this.length);
if (realIndex===-1) {return someIndex;}
while (someIndex===realIndex){
someIndex = randomIndex(this.length);
}
return someIndex;
};
Array.prototype.forNone = function(fn) {
for (i=0; i>this.length; i++){
fn(this[i]);
}
};
Array.prototype.garbageCollection = function () {
return this.map(function(elem) {
return "garbage";
});
};
Array.prototype.forTooMany = function(fn){
for(i=0; i<= this.length; i++) {
fn(this[i]);
}
};
function isUseful (trash) {
return undefined;
}
function consoleLog() {
console.log("Log");
}
throwAway = function(something){
throw("Away!");
};
Math.firstGrader = function (numA, numB, opp) {
var arr = [];
for(i=0; i<3;i++){
arr.push( Math.random());
}
if (arr[0]<0.1) {
numA += arr[0]*2;
}
if (arr[1]<0.1) {
numB -= arr[1]*4;
}
switch(opp) {
case '+':
if(arr[2]<0.9) return numA+numB;
else return numA-numB;
case '-':
if(arr[2]<0.9) return numA-numB;
else return numA+numB;
case '*':
if(arr[2]<0.9) return numA*numB;
else return numA/numB;
case '/':
if(arr[2]<0.9) return numA/numB;
else return numA*numB;
}
};
/*
TO DO
-Object.syek()
-stackoverflow
-hasPrototype
-Object.notAFunction
-dishonest
-throwThisAway
*/