Modules in JavaScript confusion
Anonymous
I am simply trying to execute below javascript code ,involving the concept of module but getting unexpected error .
I am referring modules in javascript of code academy and in codecademy platform , code is running successfully .
// index.html
<!doctype html>
<html>
<head>
<title>Page Title</title>
<meta charset="UTF-8">
<meta name="viewport" content="initial-scale=1.0">
</head>
<body>
<script src="abc.js"></script>
<script src="abcd.js"></script>
</body>
</html>
// abc.js
let Airplane = {};
Airplane.myAirplane = "StarJet";
module.exports = Airplane;
// abcd.js
const Airplane = require('./abc.js');
function displayAirplane() {
console.log(Airplane.myAirplane);
}
displayAirplane();