Cycle-writing



  • I'll draw a line with the cycles. 1_1 2 3 4 5 2 2 3 4 5 3_1 2 3 4 5 Please find a mistake.

    function t4() {
        let out = document.querySelector('.out-4');
        a = '';
        for (i = 1 ; i <=3;i++) {
            a += i + '_'
            for (k = 0; k <= 5 ; i++) {
                a += ' ';
            }
        }
        out.innerHTML = a;
    }
    

    document.querySelector('.b-4').onclick = t4;



  • function t4() {
      let a = '';
      for (let i = 1; i <= 3; i++) {
        a += i + '_'
        for (let k = 1; k <= 5; k++) {
          a += k + ' ';
        }
      }
      return a.trim();
    }
    console.log("[" + t4() + "]");




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2