fork download
  1. process.stdin.resume();
  2. process.stdin.setEncoding('utf8');
  3.  
  4. // your code goes here
  5. function punyaHuruf(kataPertama, kataKedua) {
  6. if (typeof kataPertama !== "string" || typeof kataKedua !== "string") {
  7. throw new TypeError("Kedua parameter harus berupa string");
  8. }
  9.  
  10. const a = kataPertama.toLowerCase();
  11. const b = kataKedua.toLowerCase();
  12.  
  13. for (let i = 0; i < a.length; i++) {
  14. const ch = a[i];
  15. if (!b.includes(ch)) {
  16. return false;
  17. }
  18. }
  19. return true;
  20. }
  21.  
  22. console.log(punyaHuruf('cat', 'antarctica')); // TRUE
  23. console.log(punyaHuruf('cat', 'australia')); // FALSE
  24. console.log(punyaHuruf('cat', 'ANTARCTICA')); // TRUE
  25.  
Success #stdin #stdout 0.07s 43256KB
stdin
Standard input is empty
stdout
true
false
true