0% found this document useful (0 votes)
5 views

Typescript Assignment

Uploaded by

c.jmurimiw
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Typescript Assignment

Uploaded by

c.jmurimiw
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

1. Write a function to calculate the factorial of a number.

2. Write a function to sort an array of strings alphabetically.


3. Write a function that checks if a number is prime.
4. Write a function that generates a random hex color code (e.g., #1a2b3c).
5. Write a function that multiplies each element in an array by a given multiplier.
6. Write a function that checks whether a string is a palindrome (reads the same forward and
backward).
7. Write a function that takes either a string or a number and returns a message indicating the
type. Use TypeScript type guards.
8. Write a function that combines two arrays of numbers into one without duplicates.
9. Write a function that finds the largest number in an array.
10. Create a class User with properties name and age. Add methods to update the name and
display user details.

11. Write a function that counts the number of vowels (a, e, i, o, u) in a given string
12. Create an interface Person with name (string), age (number), and isStudent (boolean).
Write a function that takes a Person object and prints a message based on their
properties.
13. Write a function that takes an array of numbers and returns a new array containing only
the even numbers.
14. Create a function that accepts two numbers and an operation (add, subtract, multiply,
divide) as a string. Return the result of the operation.
15. Write a function that takes a string and returns it reversed.

You might also like