Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getBoard(n) {
- "use strict";
- let html = `<div class="chessboard">\n`;
- for (let row = 0; row < n; row ++) {
- html += ` <div>\n`;
- for (let col = 0; col < n; col++) {
- let color = (row + col) % 2 == 0 ? 'black' : 'white';
- html += ` <span class="${color}"></span>\n`;
- }
- html += `</div>\n`;
- }
- html += `</div>`;
- return(html);
- }
- getBoard(3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement