-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmutation.js
More file actions
23 lines (18 loc) · 823 Bytes
/
mutation.js
File metadata and controls
23 lines (18 loc) · 823 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array.
// For example, ["hello", "Hello"], should return true because all of the letters in the second string are present in the first, ignoring case.
// The arguments ["hello", "hey"] should return false because the string hello does not contain a y.
// Lastly, ["Alien", "line"], should return true because all of the letters in line are present in Alien.
function mutation(arr) {
for (let i = 0; i < arr[1].length; i++) {
for (let j = 0; j < arr[0].length; j++) {
if (arr[1][i].toLowerCase() == arr[0][j].toLowerCase()) {
break;
}
if (j == arr[0].length - 1) {
return false;
}
}
}
return true;
}
mutation(["hello", "herllo"]);