fork download
  1. function tekaTekiTeko(batas) {
  2. if (typeof batas !== 'number' || !Number.isInteger(batas)) {
  3. throw new Error("Error: The provided parameter must be an integer.");
  4. }
  5.  
  6. if (batas < 20) {
  7. throw new Error("Error: The minimum value for the parameter is 20.");
  8. }
  9.  
  10. for (let i = 1; i <= batas; i++) {
  11. let output = "";
  12.  
  13. if (i % 2 === 0) {
  14. output += "Teka";
  15. }
  16. if (i % 3 === 0) {
  17. output += "Teki";
  18. }
  19. if (i % 5 === 0) {
  20. output += "Teko";
  21. }
  22.  
  23. console.log(output || i);
  24. }
  25. }
  26.  
  27. try {
  28. tekaTekiTeko(30);
  29. } catch (e) {
  30. console.error(e.message);
  31. }
Success #stdin #stdout 0.07s 40676KB
stdin
Standard input is empty
stdout
1
Teka
Teki
Teka
Teko
TekaTeki
7
Teka
Teki
TekaTeko
11
TekaTeki
13
Teka
TekiTeko
Teka
17
TekaTeki
19
TekaTeko
Teki
Teka
23
TekaTeki
Teko
Teka
Teki
Teka
29
TekaTekiTeko