Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function mutation(arr) {
- newStr = [];
- valStr = [];
- newStr = arr[0].split('');
- valStr = arr[1].split('');
- //make all lowercase for string
- for(i = 0; i < newStr.length; i++){
- holder = newStr.shift();
- holder = holder.toLowerCase();
- newStr.unshift(holder);
- }
- for(i = 0; i < valStr.length; i++){
- //make all lowercase for target
- holder2 = valStr.shift();
- holder2 = holder2.toLowerCase();
- valStr.unshift(holder2);
- }
- counter = '0';
- for(i = 0; i < valStr.length; i++){
- n = newStr.indexOf(valStr[i]);
- if(n < 0){
- return false;
- }
- counter++;
- }
- return true;
- }
- mutation(["hello", "hey"]);
- /*
- mutation(["hello", "hey"]) should return false. x
- mutation(["hello", "Hello"]) should return true. x
- mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]) should return true. x
- mutation(["Mary", "Army"]) should return true. x
- mutation(["Mary", "Aarmy"]) should return true. x
- mutation(["Alien", "line"]) should return true. x
- mutation(["floor", "for"]) should return true. x
- mutation(["hello", "neo"]) should return false. x
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement