Skip to content

Instantly share code, notes, and snippets.

@Oluwasetemi
Created September 28, 2024 18:08
Show Gist options
  • Save Oluwasetemi/a8df508cefaa4086d96d08360b0591f7 to your computer and use it in GitHub Desktop.
Save Oluwasetemi/a8df508cefaa4086d96d08360b0591f7 to your computer and use it in GitHub Desktop.
Testing modules Karatu Frontend
body {
background-color: #f0f0f0;
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
body h1 {
background-color: #333;
color: #fff;
margin: 0;
padding: 10px;
text-align: center;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Learning New Stuff</title>
<link rel="stylesheet" href="index.css">
</head>
<body>
<h1>Welcome to the old way</h1>
<!-- <script src="https://cdn.jsdelivr.net/npm/js-confetti@latest/dist/js-confetti.browser.js"></script> -->
<script type="module" src="./index.js"></script>
</body>
</html>
// import JSConfetti from 'js-confetti'
// default import - you can name it whatever you want
// import xxxx from './math.js'
// named import
import { sum, subtract } from './math.js'
// renamed import
import * as math from './math.js'
console.log(math)
// import { sum as add, subtract } from './math.js'
// console.log(xxxx)
// console.log(JSConfetti)
// alert(xxxx.sum(1, 2))
// alert(xxxx.subtract(10, 2))
// const jsConfetti = new JSConfetti()
// jsConfetti.addConfetti()
console.log('from add.js');
// named export
export const sum = (a, b) => a + b;
// const sum = (a, b) => a + b;
export const subtract = (a, b) => a - b;
// const subtract = (a, b) => a - b;
// add(1, 2); // 3
// property value shorthand - if the name of the property is the same as the name of the variable, you can omit the property value
const math = {
sum,
subtract
}
export default math; // default export
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment