Skip to content

syproo/Assignment-JS-4

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Assignment-JS-4

Assignment-JS-4

Assignment Questions

  1. Write a function that takes an array of numbers as input and returns the sum of all even numbers in the array.

  2. Write a function that takes a string as input and returns the number of vowels in the string.

  3. Write a function that takes an array of strings as input and returns the length of the longest string in the array.

  4. Write a function that takes an array of numbers as input and returns the average of all the numbers in the array.

  5. Write a function that takes an object as input and returns an array of all the keys in the object.

  6. Write a function that takes an array of objects as input and returns an array of all the values for a specified key in each object.

  7. Write a function that takes an array of strings as input and returns an array of all the unique strings in the array.

  8. Write a function that takes an array of numbers as input and returns the product of all the numbers in the array.

Example for Input and Output

  1. Function to sum all even numbers in an array: Input: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] Output: 30

  2. Function to count the number of vowels in a string: Input: "hello world" Output: 3

  3. Function to find the length of the longest string in an array: Input: ["apple", "banana", "pear", "grapefruit"] Output: 10

  4. Function to find the average of all the numbers in an array: Input: [1, 2, 3, 4, 5] Output: 3

  5. Function to return an array of all the keys in an object: Input: { name: "John", age: 30, city: "New York" } Output: ["name", "age", "city"]

  6. Function to return an array of all the values for a specified key in each object: Input: [{ name: "John", age: 30 }, { name: "Mary", age: 25 }, { name: "Peter", age: 35 }] Output: ["John", "Mary", "Peter"]

  7. Function to return an array of all the unique strings in an array: Input: ["apple", "banana", "apple", "pear", "pear", "orange"] Output: ["apple", "banana", "pear", "orange"]

  8. Function to return the product of all the numbers in an array: Input: [1, 2, 3, 4, 5] Output: 120

About

Assignment-JS-4

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published