@@ -486,3 +486,33 @@ function getIndexToIns(arr, num) {
486
486
487
487
getIndexToIns ([10 , 20 , 30 , 40 , 50 ], 35 );
488
488
```
489
+
490
+ ### 15. Mutations
491
+
492
+ _ Difficulty: Beginner_
493
+
494
+ 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.
495
+
496
+ For example, [ "hello", "Hello"] , should return ` true ` because all of the letters in the second string are present in the first, ignoring case.
497
+
498
+ The arguments ` ["hello", "hey"] ` should return ` false ` because the string ` hello ` does not contain a ` y ` .
499
+
500
+ Lastly, ` ["Alien", "line"] ` , should return ` true ` because all of the letters in ` line ` are present in ` Alien ` .
501
+
502
+ ---
503
+
504
+ #### Solution
505
+
506
+ ``` js
507
+ function mutation (arr ) {
508
+ const arr1 = arr[0 ].toLowerCase ().split (" " );
509
+ const arr2 = arr[1 ].toLowerCase ().split (" " );
510
+ for (let i = 0 ; i < arr2 .length ; i++ ) {
511
+ if (arr1 .indexOf (arr2[i]) == - 1 ) {
512
+ return false ;
513
+ }
514
+ }
515
+ return true ;
516
+ }
517
+ mutation ([" hello" , " hey" ]);
518
+ ```
0 commit comments