-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMutations.js
More file actions
23 lines (21 loc) · 822 Bytes
/
Mutations.js
File metadata and controls
23 lines (21 loc) · 822 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const mutation = (arr) => arr[1].toLowerCase().split('').every(x => arr[0].toLowerCase().split('').indexOf(x) !== -1);
/* Original Code
function mutation(arr) {
var firstStr = arr[0].toLowerCase();
var secondStr = arr[1].toLowerCase();
for (var i = 0; i < secondStr.length; i++) {
if (firstStr.indexOf(secondStr[i]) < 0) {
return false;
}
}
return true;
}
*/
mutation(["hello", "hey"]); // should return false.
mutation(["hello", "Hello"]); // should return true.
mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]); // should return true.
mutation(["Mary", "Army"]); // should return true.
mutation(["Mary", "Aarmy"]); // should return true.
mutation(["Alien", "line"]); // should return true.
mutation(["floor", "for"]); // should return true.
mutation(["hello", "neo"]); // should return false.