A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/quizzes/javascript-functions/ below:

Quiz about JavaScript Functions

What is the right output for the code below?

let count = 0;

const inc = () => ++count;

[inc(), inc(), inc()];

console.log(count);

How do you define a function in JavaScript?

What will be the output of the following code?

JavaScript
const arr = [1, 2, 3, 4, 5, 6];
const result = arr.filter(num => num % 2 === 0)
                  .map(num => num * 2)
                  .reduce((acc, curr) => acc + curr, 0);
console.log(result);

What will be the output when factorial(7) is called?

JavaScript
function factorial(n) {
  if (n === 0 || n === 1) return 1;

  let result = 1;
  function recursiveFactorial(n) {
    if (n === 2) return;
    result *= n;
    recursiveFactorial(n - 1);
  }

  recursiveFactorial(n);
  return result;
}

console.log(factorial(7));

What will typeof null return?

What happens here?

const x = () => {};

console.log(x.name);

function foo(x, y, z) {

return x + y + z;

}

const bar = foo.bind(null, 1);

console.log(bar(2, 3));

Consider the following code implementation for calculating the factorial of a number using memoization:

JavaScript
function factorial(n, memo = {}) {
  if (n <= 1) return 1;
  if (memo[n]) return memo[n];
  memo[n] = n * factorial(n - 1, memo);
  return memo[n];
}

What would happen if you call the function factorial(5) twice without modifying the memo object between the calls?

What is the output?

(function f(){

console.log(typeof f);

})();

What will the following code output?

JavaScript
const add = (a, b) => a + b;
console.log(add(5));

There are 10 questions to complete.

Take a part in the ongoing discussion


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4