-
Notifications
You must be signed in to change notification settings - Fork 0
/
question.js
49 lines (32 loc) · 2.41 KB
/
question.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// problem 1: Write a function that takes two numbers as arguments and returns their sum.
// problem 2: Write a function that takes an array of numbers as an argument and returns the largest number in the array.
// problem 3: Write a function that takes a string as an argument and returns the string in reverse order
// problem 4: Write a function that takes a number as an argument and returns the factorial of that number.
// problem 5: Write a function that takes an array of strings as an argument and returns the longest string in the array.
// problem 6: Write a function that takes an array of numbers as an argument and returns the array in reverse order.
// problem 7: Write a function that takes an array of numbers as an argument and returns the array in sorted order.
// problem 8: Write a function that takes an array of strings as an argument and returns the array in sorted order.
// problem 9: Write a function that takes an array of numbers as an argument and returns the sum of all the numbers in the array.
/**
* problem 10:
* Write a function that takes an array of numbers as an argument and returns an object with the following properties:
* sum: the sum of all the numbers in the array
* average: the average of all the numbers in the array
* isEven: true if all the numbers in the array are even, false otherwise
* */
/** problem 11:
* Create a class Person that has the following properties:
* name (string)
* age (number)
* gender (string)
* It should have a method getDetails that returns a string with the person's name, age, and gender.
*/
// problem 12: Write a function that takes an array of numbers as an argument and returns a new array with only the even numbers
// problem 13: Create a class Student that extends the Person class. It should have the following properties:
// name (string)
// age (number)
// problem 14: Write a function that takes an array of strings as an argument and returns a new array with only the strings that are longer than 5 characters
// problem 15: Write a function that takes an array of numbers as an argument and returns a new array with only the numbers that are divisible by 5
// problem 16: How can you sort an array of objects by a specific property in JavaScript?
// problem 17: How can you convert a string to title case (capitalize the first letter of each word) using JavaScript?
// problem 18: How can you check if a string contains a substring in JavaScript?