Last active
April 27, 2019 17:00
-
-
Save linxinemily/301d314937a49fc1a3dc3628b4e038c3 to your computer and use it in GitHub Desktop.
9x9-example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// data | |
const grid : HTMLElement = document.querySelector('.grid') | |
const titleCell : HTMLElement = document.querySelector('.grid-title') | |
// UI | |
function addNewElement(startNum : number) { | |
let newCell : HTMLElement = document.createElement('div') | |
newCell.className = 'grid-cell' | |
let str :string = `<div class="title">${startNum}</div>` | |
for (let i = 1; i < 10; i++) { | |
str += `<div>${startNum} x ${i} = ${startNum * i }</div>` | |
} | |
newCell.innerHTML = str | |
grid.insertBefore(newCell, titleCell.nextSibling) | |
} | |
for (let i = 9; i > 1; i--) { | |
addNewElement(i) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment