Javascript Chessboard

Javascript Chessboard

Javascript Chessboard

  • Write a program that creates a string that represents an 8×8 grid.
  • using newline characters to separate lines.
  • At each position of the grid there is either a space or a "#" character.
  • The characters should form a chessboard.
  • Passing this string to console.log should show something like this:
          #  #  #  #
        #  #  #  #
         #  #  #  #
        #  #  #  #
         #  #  #  #
        #  #  #  #
         #  #  #  #
        #  #  #  #
    

    JAVASCRIPT

    let char ="";
    for (let i = 0; i < 4; i++) {
    for (let j = 0; j < 4; j++) {
        if(i%2==0){
            char =char + " " + "#";
        }else{
            char =char + "#" + " ";
        }
    }
    console.log(char);
    char="";
    }