10 JS Interview Prep Coding Problems with solution
Q1. Write a function called sumRange . It will take a number and return the sum of all numbers from 1 up to the number passed in. output expected - sumRange(3) returns 6 = 1+2+3 Q2. Write a function called power which takes in a base and an exponent. If the exponent is 0, return 1. output expected - console.log(power(2, 2)); // 4 console.log(power(2, 1)); // 2 console.log(power(2, 0)); // 1 Q3. Write a function that returns the factorial of a number. As a quick refresher, a factorial of a number is the result of that number multiplied by the number before it, and the number before that number, and so on, until you reach 1. The factorial of 1 is just 1. output expected - factorial(5); // 5 * 4 * 3 * 2 * 1 === 120 Q4. Write a function called all which accepts an array and a callback and returns true if every value in the array returns true when passed as parameter to the callback function output ex...