fork download
  1. function sumOfDigitsTwoDigit(n) {
  2. if (n < 10 || n > 99) {
  3. return "Число должно быть двузначным";
  4. }
  5. return Math.floor(n / 10) + (n % 10);
  6. }
  7.  
  8. // Пример использования:
  9. console.log(sumOfDigitsTwoDigit(23)); // 5
  10. console.log(sumOfDigitsTwoDigit(76)); // 13
Success #stdin #stdout 0.03s 16636KB
stdin
Standard input is empty
stdout
5
13