-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path*14.mutations.js
More file actions
47 lines (36 loc) · 986 Bytes
/
*14.mutations.js
File metadata and controls
47 lines (36 loc) · 986 Bytes
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
function mutation(arr) {
var test = arr[1].toLowerCase();
var target = arr[0].toLowerCase();
for (var i=0;i<test.length;i++) {
if (target.indexOf(test[i]) < 0)
return false;
}
return true;
}
console.log(mutation(["hello", "hE"]));
function mutation(arr) {
return arr[1].toLowerCase().split('')
.every((letter) => {
return arr[0].toLowerCase()
.indexOf(letter) != -1;
});
}
console.log(mutation(["hello", "hE"]));
function mutation(arr) {
let firstWord = arr[0].toLowerCase();
let secondWord = arr[1].toLowerCase();
for (let i in secondWord){
if(firstWord.indexOf(secondWord[i]) < 0) return false;
}
return true;
}
console.log(mutation(["hello", "z"]));
function mutation(arr) {
let firstWord = arr[0].toLowerCase();
let secondWord = arr[1].toLowerCase();
for (let i in secondWord){
if(!firstWord.includes(secondWord[i])) return false;
}
return true;
}
console.log(mutation(["hello", "e"]));