사용자 및 그룹 배열을 기반으로 특정 그룹에 사용자가 있는지 알려주는이 기능이 있습니다. 지금은 참 또는 거짓이라는 표를 생성하고 있습니다. 참이면 "X", 거짓이면 "-"로 표시하고 싶습니다.
이것은 기능입니다 :
function processAll(){
for(var i=0; i<users.length; i++){
userGroupTable[users[i]] = {};
var userGroups = parseGroupCollFromUser(users[i]);
for(var j=0; j<groups.length; j++){
//if the array userGroups contains the current group, the value must be true
userGroupTable[users[i]][groups[j]] = userGroups.indexOf(groups[j]) > -1; *think this line is whats giving the result
}
}
}
줄을 다음과 같이 변경해 보았습니다.
userGroupTable[users[i]][groups[j]] = (userGroups.indexOf(groups[j]) > -1) ? " X " | " - ";
그러나 나는 얻는다 Unexpected token ;
:
대신 을 사용해야 합니다 |
.
그것은 ternary operator
다음과 같이 보입니다.
$a === $b ? true : false;
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다