Tell us what’s happening:
Hi there!
I already solved this problem while manipulating in strings. I was wondering/trying to see if I could get it to work in arrays.
Steps:
- Create a newstr and lowercase all of them
- Take the entire string and put it into a newarray using split
3)Run a for loop based on original entry arr[0] and the length of our newarray - Use indexOf on newarray to find if any -1 returns (I think this line is wrong in actual code, also cause it searches the entire array and I can’t search a portion of it)
- If -1 returns, then return False
- If all pass, return True
Any help would be great!
Your code so far
function mutation(arr) {
var newstr=arr.join('').toLowerCase();
var newarr = newstr.split('');
for (i = arr[0].length;i<newarr.length;i++){
if (newarr.indexOf(newarr[i])==-1){
return false;
}
return true;
}
}
mutation(["hello", "hey"]);
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0
.
Link to the challenge:
https://www.freecodecamp.org/challenges/mutations