w_1_2
This commit is contained in:
parent
cc75af0c6d
commit
91e4b30d1c
5
w1_2_types/README.md
Normal file
5
w1_2_types/README.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# Week 1 - Types
|
||||||
|
|
||||||
|
How to open the devtools
|
||||||
|
|
||||||
|

|
BIN
w1_2_types/assets/devtools.png
Normal file
BIN
w1_2_types/assets/devtools.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 63 KiB |
16
w1_2_types/index.html
Normal file
16
w1_2_types/index.html
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Types</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<img src="assets/devtools.png">
|
||||||
|
<script src="main.js" defer></script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
41
w1_2_types/main.js
Normal file
41
w1_2_types/main.js
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
// Types and conversions
|
||||||
|
|
||||||
|
// Ex 1 (implicit convertion)
|
||||||
|
// Compute the time in seconds
|
||||||
|
function timeInSeconds(hours, mins, secs) {
|
||||||
|
// placeholder
|
||||||
|
// return (hours * 60 + mins) * 60 + secs;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('Ex 1');
|
||||||
|
console.log(timeInSeconds(0, 0, 12));
|
||||||
|
console.log(timeInSeconds(0, 1, 12));
|
||||||
|
console.log(timeInSeconds(2, 1, 'AB'));
|
||||||
|
|
||||||
|
// Ex 2 (string templates)
|
||||||
|
// Print a student record
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
name: 'Andrea',
|
||||||
|
id: 20200212
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
function print(student) {
|
||||||
|
// placeholder
|
||||||
|
}
|
||||||
|
|
||||||
|
// console.log('Ex 2');
|
||||||
|
// print({ name: 'Andrea', id: 20200212 });
|
||||||
|
// print({ id: 20200212 });
|
||||||
|
// print(undefined);
|
||||||
|
|
||||||
|
// Ex 3 (type casting)
|
||||||
|
// Given a csv string like "andrea,20200212", create an object like the one in Ex 2
|
||||||
|
function csvToObj(csv) {
|
||||||
|
// placeholder
|
||||||
|
}
|
||||||
|
|
||||||
|
// console.log('Ex 3');
|
||||||
|
// print(csvToObj('andrea,20200212'));
|
||||||
|
// print(csvToObj('andrea'));
|
||||||
|
// print(csvToObj(undefined));
|
Loading…
Reference in New Issue
Block a user