Tell us what’s happening:
Your code so far
function diffArray(arr1, arr2) {
var newArr1 = [];
// Same, same; but different.
for (i=0;i<=arr1.length;i++){
if (arr2.indexOf(arr1[i])==-1){
newArr1.push(arr1[i]);
}}
for (i=0;i<=arr2.length;i++){
if (arr1.indexOf(arr2[i])==-1){
newArr1.push(arr2[i]);
}}
return newArr1;
}
diffArray(["diorite", "andesite", "grass", "dirt", "pink wool", "dead shrub"], ["diorite", "andesite", "grass", "dirt", "dead shrub"]);
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36 OPR/50.0.2762.58
.
Link to the challenge:
https://www.freecodecamp.org/challenges/diff-two-arrays