forked from gdsc-bit/udemy_courses
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
23 lines (22 loc) · 1.11 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
document.addEventListener("DOMContentLoaded", function () {
// Fetch the JSON data
fetch("courses.json")
.then(response => response.json())
.then(data => {
// Get the <tbody> element to populate the table
const courseTable = document.getElementById("course-table");
// Iterate through the courses and create table rows
data.forEach(course => {
const row = document.createElement("tr");
row.innerHTML = `<td>${course.course_name}</td>
<td>${course.platform}</td>
<td>${course.free_course}</td>
<td>${course.difficulty}</td>
<td>${course.module_number}</td>
<td>${course.certification === "free" ? "Free" : "Paid"}</td>
<td><a href="${course.link}" target="_blank">Visit Course</a></td>`;
courseTable.appendChild(row);
});
})
.catch(error => console.error("Error fetching data:", error));
});