This commit is contained in:
25
06_js-debug/faq/divide-example.html
Normal file
25
06_js-debug/faq/divide-example.html
Normal file
@@ -0,0 +1,25 @@
|
||||
<!doctype html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Divide</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css" rel="stylesheet" />
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<div class="container py-5">
|
||||
<h1>Divide</h1>
|
||||
</div>
|
||||
</main>
|
||||
<script>
|
||||
'use strict';
|
||||
|
||||
function divide(a) {
|
||||
return a / b;
|
||||
}
|
||||
|
||||
console.log(divide(10));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
5
06_js-debug/faq/divide.ts
Normal file
5
06_js-debug/faq/divide.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
function divide(a, b) {
|
||||
return a / b;
|
||||
}
|
||||
|
||||
console.log(divide(10));
|
||||
33
06_js-debug/faq/extraction-bsp.html
Normal file
33
06_js-debug/faq/extraction-bsp.html
Normal file
@@ -0,0 +1,33 @@
|
||||
<!doctype html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Extraction sum</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css" rel="stylesheet" />
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<div class="container py-5">
|
||||
<h1>Extraction sum</h1>
|
||||
</div>
|
||||
</main>
|
||||
<script>
|
||||
'use strict';
|
||||
const products = [
|
||||
{ name: 'Product1', price: 10.5 },
|
||||
{ name: 'Product1', price: 10.5 },
|
||||
];
|
||||
|
||||
// Extraction
|
||||
const sum = (a, b) => {
|
||||
return Number(a) + Number(b);
|
||||
};
|
||||
|
||||
const totals = products.map((product) => Number(product.price));
|
||||
const totalPrice = totals.reduce(sum, 0);
|
||||
|
||||
console.log(`total: ${totalPrice}`);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user