Skip to content

Instantly share code, notes, and snippets.

@Burick
Last active January 4, 2018 02:57
Show Gist options
  • Save Burick/1b6bc1b68b24042994622eb8f951e0cb to your computer and use it in GitHub Desktop.
Save Burick/1b6bc1b68b24042994622eb8f951e0cb to your computer and use it in GitHub Desktop.
Возвращает разность массивов
let row = [1,2,3,4,5,6,7]
let films = [4,5,6,7,8,8,9]
function diff(row,films) {
let out_arr = [];
films.forEach(element => {
let idx = row.indexOf(element);
if(idx < 0) out_arr.push(element);
console.log(`элемент ${element} - idx: ${idx}`);
});
return out_arr
}
let dif = diff(row,films);
console.log(dif);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment