Created
June 13, 2019 13:02
-
-
Save omas-public/5bb0a04f19aed6315b22f22a3e14af7d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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