fork download
  1. // your code goes here
  2. const peta = [
  3. [34, 21, 32, 41, 25],
  4. [14, 42, 43, 14, 31],
  5. [54, 45, 52, 42, 23],
  6. [33, 15, 51, 31, 35],
  7. [21, 52, 33, 13, 23],
  8. ];
  9. const soal5 = () => {
  10. const target = peta[0][3];
  11. while (peta[0][3] !== target) {
  12. for (let i = 0; i < peta.length; i++) {
  13. for (let j = 0; j < peta[i].length; j++) {
  14. console.log(peta[i][j]);
  15. if (peta[i][j] === target) {
  16. console.log("ditemukan")
  17. }
  18. }
  19. }
  20. }
  21. };
  22. console.log(soal5);
Success #stdin #stdout 0.03s 16712KB
stdin
Standard input is empty
stdout
() => {
  const target = peta[0][3];
  while (peta[0][3] !== target) {
    for (let i = 0; i < peta.length; i++) {
      for (let j = 0; j < peta[i].length; j++) {
        console.log(peta[i][j]);
        if (peta[i][j] === target) {
          console.log("ditemukan")
        }
      }
    }
  }
}