You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expect a string as an argument and the function returns a string
function returnString(text: string): string {
return text;
}
No explicit return
function sayHi(): void {
console.log("hi");
}
Type function
// expect multiply be a fn which takes 2 arguments of type number
// and that fn must return a number
let multiply: (num1: number, num2: number) => number;
Default argument's value
function countDown(start: number = 10): void {
while (start > 0) {
console.log(start);
start--;
}
}
countDown();
type Address = { street: string; streetNumber: number };
let userAddress: Address = {
street: "some street",
streetNumber: 11
};
// create your own types
type team = {
team: string;
draws: number;
wins: number;
lost: number;
};
type Scores = object[];
// endOf: create your own types
let muInfo: team = {
team: "MU",
wins: 11,
lost: 3,
draws: 11
};
let premierLeagueTeams: Scores = [muInfo];