Step 2-01 updates

This commit is contained in:
Elizabeth Craig
2019-02-27 20:17:08 -08:00
parent fdceb93839
commit 61ae8afdf1
11 changed files with 126 additions and 81 deletions

View File

@@ -1,22 +1,32 @@
// Interface for an object or class
interface Car {
make: string;
model: string;
}
class MyCar implements Car {
make: 'Honda';
model: 'Accord';
}
make: string;
model: string;
const myCar: Car = {
constructor(make: string, model: string) {
this.make = make;
this.model = model;
}
}
const myCar1: Car = new MyCar('Honda', 'Accord');
const myCar2: Car = {
make: 'Honda',
model: 'Accord'
};
// Interface as Functions
// Interface for a function
interface InterestingFn {
(someArgs: string): number;
}
const interesting: InterestingFn = (someArgs: string): number => {
return Number(someArgs);
};
// adding an export to turn this into a "module"
export default {};