신버전 part2 2번째 강의에서
input에서 받아온 데이터를 /add로 보내는 부분 듣고 있습니다.
try{
if(요청.body.inputtitle || 요청.body.inputcontent === ''){
console.log('제목 입력안함')
}
else{
await db.collection('post').insertOne({title : 요청.body.inputtitle, content: 요청.body.inputcontent})
응답.redirect('/list')
}}
질문
1. 여기서 inputtitle또는 inputcontent 가 ''일때 console.log('제목입력안함')을 하고 싶은데
두군데 다 ''이거나 inputcontent이 ''일때는 console.log('제목입력안함')이 제대로 뜨는데
inputtitle이 ''일때는 그냥 inputcontent에 있는 내용만 db로 바로 전송이 되더라고요
or연산자는 || 으로 알고 있는데 혹시 다른점이 틀린건가 궁금합니다.