-
For this exercise, you can work on your local environment (if you have the TypeScript compiler installed).
-
Or, if you prefer, you can work on an online editor like Stackblitz. For example, you can write your TypeScript code here:
https://stackblitz.com/edit/typescript-vkcluy?file=index.ts
Requirements:
- Name of the function:
greetUser
- Parameters:
userName
(a string) - required.languageCode
(a string) - optional.
- Return value:
- If language is
de
, your function should return "Guten Morgen, [userName]!". - If language is
es
, your function should return "Buenos días, [userName]!". - If language is
en
(or no language is provided), your function should return "Good morning, [userName]!".
- If language is
Requirements:
- Name of the function:
calcCircleArea
- Parameters:
radius
(a number) - required.
- Return value:
- Return the area of the circle, calculated using the formula:
PI * radius * radius
- Return the area of the circle, calculated using the formula:
- Notes:
- You may need to do some research to get the value of PI in JS.
- The returned value should be rounded to two decimal places.
- If a radius of less than or equal to 0 is provided, return null indicating an invalid radius.
Requirements:
- Name of the function:
binaryToDecimal
- Parameters:
binaryString
(a string) - required. The string should represent a binary number (e.g., '1010', '1101', '111111101').
- Return value:
- The function should return the decimal equivalent of the binary number.
- If the provided string is not a valid binary number (contains characters other than '0' and '1'), return null indicating an invalid input.
- practice TypeScript syntax with traditional functions and/or arrow functions
- implement a function
calculateRectangleArea()
- implement a function
calculateTriangleArea()
Solution: https://stackblitz.com/edit/typescript-kmbka6?file=index.ts