Skip to content

Instantly share code, notes, and snippets.

@omas-public
Created June 13, 2019 13:02
Show Gist options
  • Save omas-public/5bb0a04f19aed6315b22f22a3e14af7d to your computer and use it in GitHub Desktop.
Save omas-public/5bb0a04f19aed6315b22f22a3e14af7d to your computer and use it in GitHub Desktop.
const $ = id => document.querySelector(id)
function init() {
const fruits = ['Apple', 'Peach', 'Banana']
window.addEventListener('load', () => {
// main(fruits)
multTable(9)
})
}
function main(fruits) {
let li = null
fruits.forEach(fruit => {
li = document.createElement('li')
li.appendChild(document.createTextNode(fruit))
$('#fruits_list').appendChild(li)
})
}
init()
function multTable(n) {
let table = []
for (let i = 0, cols; i < n ; i+=1) {
cols = []
for (let j = 0; j < n; j+=1) {
cols.push((i + 1) * (j + 1))
}
table.push(cols.join(','))
}
console.log(table.join('\n'))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment