Skip to content

Commit

Permalink
Lesson 15 Code
Browse files Browse the repository at this point in the history
  • Loading branch information
tomer79sagi committed Dec 20, 2023
1 parent 8beacbe commit 83f26b1
Show file tree
Hide file tree
Showing 11 changed files with 178 additions and 0 deletions.
13 changes: 13 additions & 0 deletions 15 - 20.12.23 - Modules/modules/modules_0/array_utilities.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const name = 'Tomer Sagi';
const age = 44;

function printArray(arr) {
for (let i=0 ; i<arr.length ; i++) {
document.getElementById('output').innerHTML += `${i}. ${arr[i]}<br/>`;
}
}

export {
name,
printArray
};
25 changes: 25 additions & 0 deletions 15 - 20.12.23 - Modules/modules/modules_0/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>19.11.23</title>
<script defer type="module" src="./main.js"></script>
</head>
<body>
<h1>17.12.23</h1>
<h2>Fetch</h2>

<div id="buttons">
<button id="btnLoad">Start</button>
</div>

<hr/>

<div id="output">
<table id='myTable'>

</table>
</div>
</body>
</html>
6 changes: 6 additions & 0 deletions 15 - 20.12.23 - Modules/modules/modules_0/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { printArray } from 'array_utilities.js';

const myArr = ['Tomer', 'Gal', 'Moshe', 'Sahar'];
printArray(myArr);

// alert(`Name: ${name}`);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const name = 'Tomer Sagi';
const age = 44;

export function printArray(arr) {
for (let i=0 ; i<arr.length ; i++) {
document.getElementById('output').innerHTML += `${i}. ${arr[i]}<br/>`;
}
}
25 changes: 25 additions & 0 deletions 15 - 20.12.23 - Modules/modules/modules_1_inline_export/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>19.11.23</title>
<script defer type="module" src="./main.js"></script>
</head>
<body>
<h1>17.12.23</h1>
<h2>Fetch</h2>

<div id="buttons">
<button id="btnLoad">Start</button>
</div>

<hr/>

<div id="output">
<table id='myTable'>

</table>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { printArray } from './array_utilities.js';

const myArr = ['Tomer', 'Gal', 'Moshe', 'Sahar'];
printArray(myArr);

// alert(`Name: ${name}`);
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export const name = 'Tomer Sagi';
const age = 44;

// Expects a JS Array, iterates over it and prints every element to a DIV using 'innerHTML'
function printArray(arr) {
for (let i=0 ; i<arr.length ; i++) {
document.getElementById('output').innerHTML += `${i}. ${arr[i]}<br/>`;
}
}

export default printArray;
25 changes: 25 additions & 0 deletions 15 - 20.12.23 - Modules/modules/modules_2_default/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>19.11.23</title>
<script defer type="module" src="./main.js"></script>
</head>
<body>
<h1>17.12.23</h1>
<h2>Fetch</h2>

<div id="buttons">
<button id="btnLoad">Start</button>
</div>

<hr/>

<div id="output">
<table id='myTable'>

</table>
</div>
</body>
</html>
7 changes: 7 additions & 0 deletions 15 - 20.12.23 - Modules/modules/modules_2_default/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { name as myName, default as myPrinter } from './array_utilities.js';

const myArr = ['Tomer', 'Gal', 'Moshe', 'Sahar'];
myPrinter(myArr);
alert(myName);

// alert(`Name: ${name}`);
25 changes: 25 additions & 0 deletions 15 - 20.12.23 - Modules/oop/oop_1/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>19.11.23</title>
<script defer type="module" src="./main.js"></script>
</head>
<body>
<h1>20.12.23</h1>
<h2>OOP</h2>

<div id="buttons">
<button id="btnLoad">Start</button>
</div>

<hr/>

<div id="output">
<table id='myTable'>

</table>
</div>
</body>
</html>
27 changes: 27 additions & 0 deletions 15 - 20.12.23 - Modules/oop/oop_1/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
class Car {
// Method/function that initializes (מאתחל) a new object (מופע חדש)
constructor(make, model, year, color) {
this.make = make;
this.model = model;
this.year = year;
this.color = color;
}

printSummary() {
console.log(`
Make: ${this.make}\n
Model: ${this.model}\n
Year: ${this.year}\n
Color: ${this.color}\n
`);
}
}

const tomersCar = new Car("Hyundai", "i20", 2016, "Gray");
const saharsCar = new Car("Seat", "Ibiza", 2012, "White");

alert(tomersCar.make); // --> Hyundai
alert(saharsCar.make); // --> Seat

tomersCar.printSummary();
saharsCar.printSummary();

0 comments on commit 83f26b1

Please sign in to comment.