AND는 &&로 표현할 수 있다.
문장 전체가 참이 되려면 왼쪽과 오른쪽이 모두 참이어야 함.
예시)
true && true
→ true
true && false
→ false
const password = prompt("enter your password")
if(password.length >= 6 && password.indexOf(' ') === -1){
console.log("valid password")
} else{
console.log("wooooo")
}
조건문을 중첩하지 않아도 2가지 논리를 확인할 수 있다.
password.length >= 6 && password.indexOf(' ') === -1는 입력한 비밀번호의 길이가 6자리보다 많은지와 공백이 없는지를 확인하고 있음.