Skip to content

The-Marcy-Lab-School/foundations-practice-set-2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

foundations-practice

Question set 2

Skills Needed to Solve the Given Problems in JavaScript

1. General JavaScript Knowledge

  • Arrow Functions: Understand the syntax and usage of arrow functions (const funcName = (params) => { ... };).
  • ES6 Features: Familiarity with modern JavaScript syntax, such as const, let, and template literals.

2. Array Operations

Problem: filterEvens, getOddNumbers, sumArray, getSquareRoots, findMax, sortArray

  • Array Methods: Knowledge of array methods like:
    • .filter() for filtering elements based on a condition.
    • .map() for transforming each element of an array.
    • .reduce() for aggregating values in an array.
  • Callback Functions: Ability to write and use callback functions within array methods.
  • Mathematical Operations:
    • Modulus operator (%) for checking even/odd numbers.
    • Math.sqrt() for calculating square roots.

3. String Manipulation

Problem: reverseString, countVowels, removeSpaces, capitalizeWords

  • String Methods:
    • .split('') to convert a string into an array of characters.
    • .join('') to combine an array of characters into a string.
    • .toLowerCase() and .toUpperCase() for case transformations.
    • .trim() to remove unnecessary spaces.
  • Regular Expressions (optional):
    • Use match() to count vowels.
    • Use replace() to remove spaces or modify strings based on patterns.
  • Looping Over Strings:
    • Use for...of loops or array methods to iterate over each character in a string.

4. Working with Numbers

Problem: countVowels, getSquareRoots, findMax

  • Math Object:
    • Math.sqrt() for square root calculations.
    • Math.max() for finding the maximum value in an array (can also use reduce()).
  • Basic Arithmetic:
    • Summing numbers using addition.
    • Understanding operators (+, %, etc.).

5. Sorting and Transformation

Problem: sortArray, capitalizeWords

  • Sorting Numbers:
    • Use .sort() with a comparison function: (a, b) => a - b for ascending order.
  • String Transformation:
    • Combine .split(' '), .map(), and .join(' ') to modify each word in a string (e.g., capitalize the first letter).

6. Problem-Specific Logic

  • Conditionals: Using if statements or ternary operators to handle different scenarios.
  • Edge Cases:
    • Handle empty arrays or strings.
    • Consider special characters or mixed-case strings.

7. Testing and Debugging

  • Testing Functions: Write test cases to check the correctness of the functions.
  • Console Debugging: Use console.log() to understand the behavior of code at different stages.

By mastering these skills, you can effectively solve each of the given problems and improve your overall proficiency in JavaScript.

  1. Write an arrow function filterEvens that filters even numbers from an array.

  2. Create an arrow function sumArray that sums all numbers in an array.

  3. Define an arrow function getOddNumbers that returns only odd numbers from an array.

  4. Write an arrow function reverseString that reverses a given string.

  5. Create an arrow function countVowels that counts the number of vowels in a string.

  6. Write an arrow function removeSpaces that removes all spaces from a string.

  7. Define an arrow function getSquareRoots that returns an array of square roots from a given array of numbers.

  8. Write an arrow function capitalizeWords that capitalizes the first letter of each word in a string.

  9. Create an arrow function findMax that finds the largest number in an array.

  10. Write an arrow function sortArray that sorts an array of numbers in ascending order.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published