-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic-8.ts
More file actions
54 lines (45 loc) · 1.26 KB
/
Copy pathbasic-8.ts
File metadata and controls
54 lines (45 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Function type :
function makeChai(type:string, cups:number) {
console.log(`Making ${cups} cups of ${type}`);
}
// makeChai("Masala", "2"); // Error: Argument of type 'string' is not assignable to parameter of type 'number'.
makeChai("Masala", 2);
function getChaiPrice():number {
// return "10 rupees"; // Error: Type 'string' is not assignable to type 'number'.;
return 10;
}function getChaiPrices() {
return 10;
}
function makeOder(orderType:string) {
if (!orderType) return null
return orderType
// return `Order received for ${orderType} chai`;
}
function makeOdered(orderType:string):string | null {
if (!orderType) return null
return orderType
// return `Order received for ${orderType} chai`;
}
function logChai():void {
console.log("Chai is ready");
}
function oderChai(type?:string) {
console.log('Chai order received');
}
function oderChai(type:string = "Masala") {
console.log('Chai order received');
}
function createChai(order:{
type:string,
sugarLevel:number;
size:"small" | "medium" | "large"
}){
console.log();
}
function createChais(order:{
type:string,
sugarLevel:number;
size:"small" | "medium" | "large"
}):number{
return 10;
}