0% found this document useful (0 votes)
23 views3 pages

JAVA SCRIPT

Java Script Practice Questions

Uploaded by

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

JAVA SCRIPT

Java Script Practice Questions

Uploaded by

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

JAVA SCRIPT (1) ------>

1. Write a function that takes two numbers as arguments and


returns their sum.

2. Write a function that takes a string as an argument and returns its


length.

3. Write a program that takes two numbers and displays their sum,
difference, product, and quotient.

4. Write a function that takes two numbers as arguments and


returns the larger number.

5. Write a program that displays a string in reverse order.

6. Write a program that takes a number and checks whether it is


positive, negative, or zero.

7. Write a program that takes a number and prints the


multiplication table for that number.

8. Write a program that takes a number and calculates the sum of all
numbers from 1 to that number.

9. Write a program that takes a string and prints out the number of
vowels in the string.
10. Write a function that takes two arrays of integers as arguments
and returns an array of the common elements in both arrays,
without any duplicates. The returned array should be sorted in
ascending order.
For example, given the arrays [1, 2, 3, 4, 5] and [3, 4, 5, 6, 7], the
function should return [3, 4, 5].
Hint: You may need to use nested loops and conditional statements
to solve this problem.

JAVA SCRIPT (2) ------->

1. Write a function called 'greet' that takes a name parameter and


logs a greeting message to the console.

2. Write a function called 'getSquare' that takes a number parameter


and returns its square.

3. Write a function called 'countLetters' that takes a string


parameter and returns an object that contains a count of each letter
in the string.

4. Write a function called 'createCounter' that returns a function.


The returned function should increment a counter variable each time
it is called and return the current count.
5. Write a function called 'sumEvenNumbers' that takes an array of
numbers as a parameter and returns the sum of all even numbers in
the array.

6. Write a function that takes an array of numbers as an argument


and returns the sum of all the numbers in the array.

7. Write a function that takes an array of strings as an argument and


returns a new array with only the strings that have a length greater
than 5.

8. Write a function that takes an object and returns an array of all


the keys in the object.

9. Write a function that takes an array of objects and returns an


array of all the values of a specified property name.

10. Write a function that takes an array of objects and returns the
object with the highest value for a specified property name.

You might also like