Answers for "find array object value is already in use"

1

find array object value is already in use

function add(name) {
    var id = arr.length + 1;        
            if (arr.filter(item=> item.username == name).length == 0){
            arr.push({ id: id, username: name });
        }
}
Posted by: Guest on February-19-2021

Code answers related to "find array object value is already in use"

Code answers related to "Javascript"

Browse Popular Code Answers by Language