fork download
  1. function allDigitsDifferent(n) {
  2. if (n < 100 || n > 999) {
  3. return "Число должно быть трехзначным";
  4. }
  5. const digits = String(n).split('');
  6. return new Set(digits).size === 3;
  7. }
  8.  
  9. // Пример использования:
  10. console.log(allDigitsDifferent(123)); // true
  11. console.log(allDigitsDifferent(121)); // false
  12. console.log(allDigitsDifferent(111)); // false
Success #stdin #stdout 0.03s 16728KB
stdin
Standard input is empty
stdout
true
false
false