kyler decides delete account. loop through array of objects until find kyler's account - use kyler@test.com find him in array. once find particular index he's located in, delete him array.
var users = [{ name: 'talon', email: 'talon@test.com', password: 'test1234', username: 'tdog', },{ name: 'lauren', email: 'lauren@test.com', password: 'admin1234', username: 'ldogg', },{ name: 'cohen', email: 'cohen@test.com', password: 'baby1234', username: 'cdoggy', },{ name: 'kyler', email: 'kyler@test.com', password: 'delete1234', username: 'kdawg' }];
this have far, spinning wheels:
function deleteuser(arr) (var = 0; < users.length; i++) { if (arr.indexof([i]) === 'kyler@test.com') { users.slice(arr[i]); } }
i not sure if each of users needs variable assigned in array or if slice. guidance awesome. thanks
since want mutate original array need splice
function deleteuser(arr, email) { for(var = 0; < arr.length; i++) { if(arr[i].email === email) { arr.splice(i, 1) return; } } }
Comments
Post a Comment