문제
문자열의 모든 문자가 한 번만 나타나면 true를 반환하고 그렇지 않으면 false를 반환하는 JavaScript 함수를 작성해야 합니다.
예시
다음은 코드입니다 -
const str = 'thisconaluqe';
const allUnique = (str = '') => {
for(let i = 0; i < str.length; i++){
const el = str[i];
if(str.indexOf(el) !== str.lastIndexOf(el)){
return false;
};
};
return true;
};
console.log(allUnique(str)); 출력
true