I'm having an issue when using document.querySelectorAll("select") to link to my HTML code and I'm not sure why
// Linking quotes_list.csv file to main
const fs = require('fs');
// Read the CSV file
fs.readFile('quotes_list.csv', 'utf8', (err, data) => {
if (err) {
console.error('Error reading the file:', err);
return;
}
// Split the CSV data into rows
const rows = data.split('\n');
// Initialize an array to store the parsed data
const dataArray = [];
// Loop through each row and split it into columns
for (let i = 0; i < rows.length; i++) {
dataArray.push(rows[i]);
}
// Print the parsed data array
console.log(dataArray);
});
//Link HTML to JavaScript
let selectMenu = document.querySelectorAll("select");
//Main code
for (let i = 12; i < 0; i--) {
i = i < 10 ? "0" + i : i;
let option = `<option value="${i}">${i}</option>`;
selectMenu[0].firstElementChild.insertAdjacentHTML("afterend", option);
}```
-
``` HTML
<html>
<head>
<title>Motivational Alarm</title>
<link rel="stylesheet" href="style.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div class="wrapper">
<h1>12:23:30 AM</h1>
<div class="content">
<div class="column">
<select>
<option value="Hour" selected hidden>Hour</option>
</select>
</div>
<div class="column">
<select>
<option value="Minute" selected hidden>Minute</option>
</select>
</div>
<div class="column">
<select>
<option value="AM/PM" selected hidden>Hour</option>
</select>
</div>
</div>
<button>Set Alarm</button>
</div>
<script src="main.js"></script>
</body>
</html>```
This is the full error I get.
``` JavaScript
Uncaught ReferenceError ReferenceError: document is not defined
at <anonymous> (file:///C:/Users/Praze/PROJECTS/Motivation%20Project/VersionOne/main.js:28:18)
at Module._compile (node:internal/modules/cjs/loader:1254:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Module._load (node:internal/modules/cjs/loader:958:12)
at executeUserEntryPoint (node:internal/modules/run_main:81:12)
at <anonymous> (node:internal/main/run_main_module:23:47)