Skip to content
Open
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
34 changes: 33 additions & 1 deletion src/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
*/
function printName(name: string): void {
// write your code here
console.log(name);
}



/**
* Task 2:
* Create a function named `printAge`
Expand All @@ -17,8 +20,13 @@ function printName(name: string): void {
*/
function printAge(birthYear: number): void {
// write your code here
const currentYear = 2025;
const age = currentYear - birthYear;
console.log(age);
}



// example:
printAge(2000); // => 2025 (2025 - 2000)

Expand All @@ -38,10 +46,32 @@ printAge(2000); // => 2025 (2025 - 2000)
// don't make any changes to LanguageType
type LanguageType = "en" | "es" | "fr" | "tr";

function printHello(name: string, language: LanguageType): void {

// write your code here
function printHello(name: string, language: LanguageType): void {
let greeting = "";

switch (language)
{
case "en":
greeting = "Hello";
break;
case "es":
greeting = "Hola";
break;
case "fr":
greeting = "Bonjour";
break;
case "tr":
greeting = "Merhaba";
break;
}

console.log(`${greeting} ${name}`);
}



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

// example:
Expand Down