I'm trying to instantiate a JavaScript class in another HTML file.
Here is the JavaScript class:
class Puzzle {
constructor(fenStart, pgnEnd) {
this.fenStart = fenStart;
this.pgnEnd = pgnEnd;
}
}
module.exports = Puzzle;
And here is the HTML file:
<!DOCTYPE html>
<html>
<body>
<script src="jquery-3.2.1.min.js"></script>
<script src="class.js"></script>
<p id="demo"></p>
<script>
var demoEL = $('#demo');
const x = new Puzzle("fenStart", "pgnEnd");
demoEL.html(x.fenStart);
</script>
</body>
</html>
However when ever I open the HTML file in chrome nothing appears on the page. And in the developer console I get the error "Uncaught ReferenceError: module is not defined, at class.js:8" How can I properly instantiate the puzzle class in this HTML file?
PS: I read that JQuery might be needed for this so I downloaded "jquery-3.2.1.min.js" and included it in the same folder as the JavaScript class and the HTML file.