Last active
October 12, 2022 06:08
-
-
Save jcchikikomori/a9c0ee7bd2a09994977f570b20648b7c to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Javascript Quiz</title> | |
<script src="quiz.js" ></script> | |
</head> | |
<body > | |
<div id="mainDiv"> | |
<button onclick="displayEmployees()">Display Employees</button> | |
</div> | |
</body> | |
</html> |
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
const displayEmployees = () => { | |
const employees = [ | |
{name:"AQUINO, REX BRAYAN", address:"Camp Sawi, Cagayan de Oro City"}, | |
{name:"CHAN, JENNIE MAE", address:"Camp Kolera, Bukidnon"}, | |
{name:"DAGOHOY, RENEE FE", address:"Camp Panuhot, Bukidnon"}, | |
{name:"AUDITOR, MARK JUSTINE", address:"Camp Butod, Butuan City"}, | |
{name:"VERANO, DANIEL", address:"Camp Almoranas, Malaybalay City"}, | |
{name:"CASTRO, ANGEL KRIS", address:"Camp Maligaya, Cagayan de Oro City"}, | |
{name:"RABOR, IRISH", address:"Camp Almoranas, Malaybalay City"}, | |
{name:"CAPILITAN, KYLE", address:"Camp Kolera, Bukidnon"}, | |
{name:"CASICAS, RAZEL", address:"Camp Sawi, Cagayan de Oro City "}, | |
{name:"MAHINAY, ALGEN RIO", address:"Camp Maligaya, Cagayan de Oro City"} | |
]; | |
var table = document.createElement("table"); | |
table.setAttribute("border", "1"); | |
const thead = table.createTHead(); | |
var tr = thead.insertRow(); | |
tr.insertCell().textContent = "NAME"; | |
tr.insertCell().textContent = "ADDRESS"; | |
table.appendChild(thead); | |
const tbody = table.createTBody(); | |
var h = ``; | |
employees.forEach(emp =>{ | |
h += ` | |
<tr> | |
<td>${emp.name}</td> | |
<td>${emp.address}</td> | |
</tr> | |
`; | |
}) | |
tbody.innerHTML = h; | |
table.appendChild(tbody); | |
const mainDiv = document.getElementById("mainDiv"); | |
mainDiv.appendChild(table); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment