This repository contains a set of JavaScript programming challenges together with the solutions.
Challenge Questions: All of the challenges are listed below.
Solutions: The links to the solutions are provided below the questions.
CHALLENGES:
1. Check Nums:
Have the function checkNums(num1,num2)
take both parameters being passed and print true if num2 is greater than num1, otherwise print false.
If the parameter values are equal to each other then print -1.
2. Compare Strings: Create a function that takes two strings as arguments and return either true or false depending on whether the total number of characters in the first string is equal to the total number of characters in the second string.
3. Concatenate Arrays: Create a function to concatenate two integer arrays.
4. Count The Vowels: Create a function that takes a string and print the number of vowels contained within it.
5. Date & Time: 📅 - Print the current date and time in default format. - Print the current date and time in localised style. - Print the current date and time with a pattern.
6. Divisible by 5: Create a function that prints true if an integer is divisible by 5, and false otherwise.
7. Factorial: This challenge requires you to return the factorial of a given number. A factorial of a number (num), is num multiplied by (num-1) multiplied by (num-2) and so forth until you reach the number 1. For example, the factorial of 4 is 4 * 3 * 2 * 1 = 24. Loop from 1 to num, multiplying each number by the previous one, until you reach the number.
8. Fibonacci: The Fibonacci Sequence is a sequence of numbers whose sum is the two preceding numbers (e.g. 0, 1, 1, 2, 3, etc). Using 0 and 1 as the starting values, create a function that prints an array containing all of the Fibonacci numbers up to 10000.
9. FizzBuzz: Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.
10. Capitalise Letters: Create a function that converts the first character of each word to uppercase. Print the newly formatted string.
11. Multiply and Skip: Print the multiples of 5 whilst skipping the multiples of 3.
12. NameChange:
Change your surname using a constructor function, the changeName function and an object instance.
13. Palindrome: Given a string of text, print true or false indicating whether or not the text is a palindrome. A palindrome is a word, number, or other sequence of characters which reads the same backward as forward, such as "madam" or "racecar". You can also create an int palindrome.
14. Remove Characters: Remove the first and last characters from a string.
15. Share the Cake: 🍰 Create a function that determines whether or not it's possible to share the cake fairly given these three parameters: Total slices, Recipients, Slices each. It's fine not to use the entire cake. Print true if the cake can be shared equally, otherwise print false.
16. Format Phone Number:
Create a function that takes an array of 10 numbers between 0 and 9 and returns a string of numbers formatted as a phone number.
The function call should resemble something like this: formatPhoneNumber(4, 4, 1, 2, 3, 4, 5, 6, 7, 8).
17. Find the area of a triangle: Write a function that takes the base and height of a triangle and print its area. Solution
18. Longest word: Write a function that takes in (sen) as a parameter and prints the longest word in a sentence.
19. Missing angle: Create a function that classifies the missing angle as either "acute", "right", or "obtuse" based on its degrees. Provide two numbers as arguments and calculate the missing degree by adding the two numbers and subtracting that from 180.
20. Number limit: Write a function which takes three number arguments (one number as an input and the other two numbers representing the lowest and highest points of the range). If the number falls within the range, print the number. If the number is less than the lower limit of the range, print the lowest limit number and if the number is greater than the upper limit of the range, print the highest limit number.