Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Problem] Checking if an element exists in array #30

Open
njs03332 opened this issue Jun 2, 2018 · 1 comment
Open

[Problem] Checking if an element exists in array #30

njs03332 opened this issue Jun 2, 2018 · 1 comment
Labels
question Further information is requested

Comments

@njs03332
Copy link
Collaborator

njs03332 commented Jun 2, 2018

CheckAttendance에서
selected라는 array가 {id: ~, username: ~} 이렇게 생긴 element들을 저장하고 있는데
이 안에 member = {id: , username: } 이렇게 생긴 애가 존재하느냐 안하느냐에 따라서 더해주거나 빼주거나 하고싶어!
구글링 끝에 .includes 대신 .indexOf(~~) == -1 이걸 쓰라고 되어있길래 해봤는데도 안되네
if (selected.indexOf(member) != -1) {
selected.splice(id, id)
console.log("deleted selected", selected)
}
else {
selected.push(member)
console.log("added selected", selected)
}

이렇게 해놨고든...
그냥 else문만 계속 돌아가는 상황이야ㅠ

참고로 푸시는 아직 안해놨엉

@njs03332 njs03332 added the question Further information is requested label Jun 2, 2018
@ilil96
Copy link
Collaborator

ilil96 commented Jun 3, 2018

헐...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants