Skip to content
Open

done #18

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,21 @@
*/
function printName(name: string): void {
// write your code here
console.log(name);
}

/**
* Task 2:
* Create a function named `printAge`
* - Accepts a "birthYear" parameter of type "number"
* Create a function named ` AccepprintAge`
* -ts a "birthYear" parameter of type "number"
* - and prints (logs) the age on the screen
* - Age = current year - birth
*/
function printAge(birthYear: number): void {
// write your code here
const currentyear = new Date().getFullYear();
const age = currentyear - birthYear;
console.log(age);
}

// example:
Expand All @@ -40,6 +44,15 @@ type LanguageType = "en" | "es" | "fr" | "tr";

function printHello(name: string, language: LanguageType): void {
// write your code here
if (language === "en") {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also use Switch cases here instead of if else

console.log(`Hello ${name}`);
} else if (language === "es") {
console.log(`Hola ${name}`);
} else if (language === "fr") {
console.log(`Bonjour ${name}`);
} else if (language === "tr") {
console.log(`Merhaba ${name}`);
}
}

// example:
Expand All @@ -56,6 +69,7 @@ printHello("Aziz", "fr"); // => "Bonjour Aziz"
*/
function printMax(x: number, y: number) {
// write your code here
console.log(x > y ? x : y);
}

// example:
Expand Down