JavaScript Basic Exercises

This repository contains basic JavaScript exercises. Each exercise focuses on a different fundamental concept in JavaScript, including:

  • Function operations
  • Variables usage
  • Loop structures
  • Conditionals

Exercise Descriptions

  1. isEven(number): Checks if a number is even.
  2. factorial(n): Computes the factorial of a number.
  3. isPrime(n): Checks if a number is prime.
  4. fibonacci(n): Computes the nth number in the Fibonacci sequence.
  5. gcd(a, b): Finds the greatest common divisor of two numbers.
  6. power(base, exponent): Computes the base raised to the power of the exponent.
  7. isPalindrome(string): Checks if a string is a palindrome.
  8. countChar(string, char): Counts the number of times a character appears in a string.
  9. sumDigits(n): Computes the sum of the digits of a number.
  10. reverseString(string): Reverses a string.

Testing

We use Jest for testing. To run the tests, navigate to the project directory in your terminal and run:

npm test