fork download
  1. function checkNumberOfLetters(str) {
  2. const splitedStr = str.trim().split('');
  3.  
  4. const charCout = splitedStr.reduce((acc, curr) => {
  5. acc[curr] = (acc[curr] || 0) + 1;
  6.  
  7. return acc;
  8. }, {});
  9.  
  10. for (const [key, value] of Object.entries(charCout)) {
  11. if (value === 2) {
  12. return str;
  13. }
  14. }
  15.  
  16. return null;
  17. }
Success #stdin #stdout 0.03s 16488KB
stdin
Standard input is empty
stdout
Standard output is empty