-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtesting.js
62 lines (40 loc) · 991 Bytes
/
testing.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
function replaceWith(word, replace, replacer) {
var wordz = word.split('');
var newWord = [];
for(var i = 0; i < word.length; i++) {
if(word[i] === replace) {
newWord[i] = replacer;
} else {
newWord[i] = word[i];
}
}
return newWord.join('');
}
function expand(array, number) {
var array1 = [];
for(var i = 1; i <= number; i++) {
array1 = array1.concat(array);
}
return array1;
}
function acceptNumbersOnly(n) {
for(var i = 0; i < arguments.length; i++) {
if(isNaN(arguments[i]) === true || typeof arguments[i] !== 'number') {
return false;
}
}
return true;
}
function mergeArrays(a1, a2) {
return a1.concat(a2).sort(function (a, b) { return a - b; });
}
function mergeObjects(obj1, obj2) {
var mergedObject = {};
for(var key in obj1) {
mergedObject[key] = obj1[key];
}
for(var key1 in obj2) {
mergedObject[key1] = obj2[key1];
}
return mergedObject;
}