Signup/Sign In

Guess the Output - Part 5 Test

JavaScript Avg. Score: 1.99 233 Beginner
Q.1 What will be the output of the following code?
const arr = [7, 9, 11];
const result = arr.map(x => {
  arr.push(x * 2);
  return x * 2;
});

console.log(arr);

 

Q.2 What will be the output of the following code?
function foo() {
    return bar();
    function bar() {
        return 'hello';
    }
}
console.log(foo());
Q.3 What will be the output of the following code?
const obj = {
  name: 'John',
  greet: function() {
    console.log(`Hello, ${this.name}`);
  }
};
const greet = obj.greet;
greet();
Q.4 What will be the output of the following code?
const num = 10;
function multiplyBy2(num) {
  console.log(num * 2);
}
console.log(multiplyBy2(num));
Q.5 What will be the output of the following code?
const nums = [10, 20, 30, 40];
const result = nums.reduce((acc, num) => acc + num, 0);
console.log(result);

Studytonight logo

Find me on YouTube

I make videos for Fullstack Dev, AWS, Ethical Hacking and Foundational stuff.