The Complete Guide to Modern JavaScript Educative Quiz Answers

Get The Complete Guide to Modern JavaScript Educative Quiz Answers

Whether you are a complete beginner or you have some knowledge of JavaScript, this course will guide you from the basics of the language to all the new features introduced up until 2021. You’ll test your knowledge with quizzes and some coding challenges at the end of each chapter.

After following this course, the functions and variables let, const, generators, promises and async won’t be a problem anymore.

If you want to experience something new, this course also includes an introduction to the basics of TypeScript, which is a must-know for any JavaScript developer.

Enroll on Educative

Quiz 1:

Q1. Which of the following ways of naming a variable is wrong?

  • var very_important = "very_important"
  • var important_999 = "important_999"
  • var important! = "important!"
  • var VeRY_ImP_orTant = "VeRY_ImP_orTant"

Q2. Which one of the following is not a real Primitive?

  • symbol
  • boolean
  • null
  • Object

Q3. What is the correct way of defining an Object?

  • const car: { color: "red"}
  • const car = {color = "red"}
  • const car = { color: "red" }
  • const car: {color = "red"}

Q4. What is the correct output of the following code?

const obj1 = {a: 1};
const obj2 = {a: 1};

console.log(obj1 === obj2);
  • true
  • undefined
  • false
  • null

Q5. What is the correct output of the following code?

const fruitBasket = ['apple','banana','orange'];
fruitBasket.unshift('melon')
console.log(fruitBasket);
  • ["apple", "banana", "orange", "melon"]
  • ["melon"]
  • ["apple", "banana", "orange", "pear", "melon"]
  • ["melon", "apple", "banana", "orange"]

Quiz 2:

Q1. What is the correct output of the following code?

var greeting = "Hello";

greeting = "Farewell";

for (var i = 0; i < 2; i++) {
  var greeting = "Good morning";
}
console.log(greeting);
  • Hello
  • Good morning
  • Farewell

Q2. What is the correct output of the following code?

let value = 1;

if(true) {
  let value = 2;
  console.log(value);
}

value = 3;
  • 1
  • 2
  • 3

Q3. What is the correct output of the following code?

let x = 100;

if (x > 50) {
  let x = 10;
}

console.log(x);
  • 10
  • 100
  • 50

Q4. What is the correct output of the following code?

console.log(constant);

const constant = 1;
  • ReferenceError
  • undefined
  • 1

Quiz 3:

Q1.What is the correct syntax for an arrow function?

let arr = [1,2,3];
  • Code 1
let func = arr.map(n -> n+1);
  • Code 2
let func = arr.map(n => n+1);
  • Code 3
let func = arr.map(n ~> n+1);

Q2. What is the correct output of the following code?

const person = {
  age: 10,
  grow: () => {
    this.age++;
  },
}
person.grow();

console.log(person.age);
  • 10
  • 11
  • undefined

Quiz 4:

Q1. What is the correct output of the following code?

var b = 3;
function multiply(a,b=2){
  return a * b;
}
console.log(multiply(5));
  • 2
  • 5
  • 10
  • 15

Quiz 5:

Q1. What is the correct output of the following code?

const code = "ABCDEFGHI";

code.startsWith("DEF",3);
  • true
  • false

Q2. What is the correct output of the following code?

const code = "ABCDEF";
code.endsWith("def");
  • true
  • false

Quiz 6:

Q1. Which one of these loops was introduced in ES6?

  • while
  • for of
  • for in

Q2. What is the correct output of the following code?

let people = [ "Tom", "Jerry", "Mickey" ];

for (let person of people){
  console.log(person);
}
  • Tom Jerry
  • Tom
  • Tom Jerry Mickey
  • Mickey

Quiz 7:

Q1. What is the correct output of the following code: Array.from([1, 2, 3], x => x * x);

  • [1,2,3]
  • [1,4,9]
  • [1,3,5]

Q2. What is the correct output of the following code?

const array = [1,2,3,4,5,6,1,2,3,1];
let arraySome = array.some( e => e > 2);

console.log(arraySome);
  • 2
  • false
  • 3
  • true

Q3. What is the correct output of the following code?

const array = [1,2,3,4,5];
let found = array.find( e => e > 3 );

console.log(found);
  • 3
  • 5
  • 4,5
  • 4

Quiz 8:

Q1. What is the correct syntax to spread the values of an array?

  • [.]
  • (…)
  • […]
  • {…}

Q2. What is the correct output of the following code?

let arr = [ 1, 2, 3, 4];

let arr2 = arr;

arr2.push(5);
console.log(arr);
  • [1, 2, 3, 4]
  • [1, 2, 4, 5]
  • [1, 2, 3, 4, 5]
  • “1, 2, 3, 4, 5”

Quiz 9:

Q1. What is the correct output of this code:

const name = "myname";
const person = {
  [name]:"Alberto",
};
console.log(person.myname);
  • name
  • “name”
  • “Alberto”
  • myname

Q2. What is correct output of the following code:

const name = "myname";
const age = 27;
const favoriteColor = "Green";
const person = {
  name,
  age,
  color
};
console.log(person.color);
  • “Green”
  • color
  • color is not defined
  • favoriteColor

Quiz 10:

Q1. What is a symbol?

  • a caveman
  • a property
  • a primitive
  • a type of function

Q2. What is the main characteristic of a symbol?

  • they will throw an error when trying to re-assign their value
  • they don’t work inside a for loop
  • they are unique
  • they can only hold strings and not integers

Q3. What is the correct output of the following code?

const friends = {
  "Tom" : "bff",
  "Jim" : "brother",
  "Tom" : "cousin",
}

for (friend in friends){
  console.log(friend);
}
  • Jim Tom
  • Error
  • Tom Jim Tom
  • Tom Jim

Q4. What is the correct output of the following code?

const family = {
  [Symbol("Tom")] : "father",
  [Symbol("Jane")] : "mother",
  [Symbol("Tom")] : "brother",
};

const symbols = Object.getOwnPropertySymbols(family);
console.log(symbols);
  • Symbol(Tom) Symbol(Jane) Symbol(Tom)
  • Symbol(Tom) Symbol(Jane)
  • undefined
  • Symbol(Jane) Symbol(Tom)

Quiz 11:

Q1. What is a class?

  • a new primitive
  • just syntactic sugar to perform prototypal inheritance
  • a new type of array

Q2. How can you create a class? Select all that apply

  • const person = class Person {…}
  • const person = new class Person {…}
  • class Person {…}

Q3. What is a static method?

  • A method that can’t change
  • A method that can be accessed by every instance of a class
  • A method that can be accessed only by the class itself

Q4. What is the correct output of the following code?

class Person {
  constructor(name,age){
    this.name = name;
    this.age = age;
  }
}
class Adult extends Person {
  constructor(work){
    this.work = work;
  }
}

const my = new Adult('software developer');
console.log(my.work);
  • “software developer”
  • Error: age is not defined
  • ReferenceError: Must call super constructor in derived class before accessing ‘this’

Quiz 12:

Q1. What is a Promise?

  • a new primitive
  • is an object representing the eventual completion or failure of an asynchronous operation
  • a new type of loop

Q2. Which of the following promise methods does not exist?

  • Promise.race()
  • Promise.some()
  • Promise.all()
  • Promise.reject()

Q3. What is the correct output of the following code:

function myPromise(){
    return new Promise((resolve,reject) => {
        reject();
    })
}

myPromise()
    .then(() => {
        console.log('1')
    })
    .then(() => {
        console.log('2')
    })
    .catch(() => {
        console.log('3')
    })
    .then(() => {
        console.log('4')
    });
  • 1,2,3,4
  • 3,4,1,2
  • 3,4
  • 4

Quiz 13:

Q1. What is the correct syntax of a generator function?

  • Code 1
generator function() {...}
  • Code 2
new generator(){...}
  • Code 3
function*(){...}

Q2. What is the main feature of a generator?

  • It can’t be stopped
  • It can generate other functions
  • It can’t be overwritten
  • It can be stopped and restarted

Q3. What is the last output of the following code?

function* fruitList(){
  yield 'Banana';
  yield 'Apple';
  yield 'Pomelo';
  yield 'Mangosteen';
  yield 'Orange';
}

const fruits = fruitList();

fruits;
fruits.next();
fruits.next();
fruits.next();
  • Code 1
Object { value: "Banana", done: false }
  • Code 2
Object { value: "Pomelo", done: true }
  • Code 3
Object { value: "Mangosteen", done: false }
  • Code 4
Object { value: "Pomelo", done: false }

Q4. What is the correct output of the following code?

function* fruitList(){
  yield 'Banana';
  yield 'Apple';
  yield 'Orange';
}

const fruits = fruitList();

fruits.return();
  • Code 1
Object { value: "Banana", done: true }
  • Code 2
Object { value: "Banana", done: true }
  • Code 3
Object { value: "Banana", done: false }
  • Code 4
Object { value: undefined, done: true }

Quiz 14:

Q1. What is the use of a Proxy?

  • to store unique values
  • to define custom behavior of fundamental operations
  • to make a value inaccessible from other functions

Q2. How many parameters can a Proxy take?

  • 1
  • 2
  • 3
  • 4

Q3. Which of the following is correct:

  • The target parameter of a Proxy must be an Array
  • The target parameter of a Proxy must not be an Array
  • The target parameter of a Proxy can be another Proxy
  • The target parameter of a Proxy cannot be another Proxy

Quiz 15:

Q1. Which one of these does not exist?

  • Set
  • WeakSet
  • StrongSet
  • WeakMap

Q2. Which one of the following definition is correct?

  • Set can only store objects
  • WeakSet can only store objects
  • WeakSet can be overwritten
  • Both Set and WeakSet can only store objects

Q3. Which one of the following definition is correct?

  • Map only stores keys
  • Set stores both keys and values, a Map only values
  • Map stores both keys and values, a Set only values
  • none, they both stores only values

Quiz 16:

Q1. What new array method was introduced in ES2016?

  • Array.prototype.contains()
  • Array.prototype.has()`
  • Array.prototype.includes()
  • Array.prototype.find()

Q2. What is the correct output of the following code?

let array = [1,3,5,7,9,11];

array.includes(5,4);
  • 4
  • true
  • 5
  • false

Quiz 17:

Q1. What is the correct output of the following code?

"hello".padStart(6);
  • ” hello “
  • “hello “
  • ” hello”
  • “hello”

Q2. Which of the following was not added in ES2016?

  • Object.entries()
  • Object.keys()
  • Object.values()

Q3. What is the correct ouput of the following code:

const buffer = new SharedArrayBuffer(16);
const uint8 = new Uint8Array(buffer);

uint8[0] = 10;

console.log(Atomics.add(uint8, 0, 5));
  • 0
  • 10
  • 15
  • 5

Q4. What is the correct output of the following code:

const buffer = new SharedArrayBuffer(16);
const uint8 = new Uint8Array(buffer);

uint8[0] = 10;

Atomics.sub(uint8, 0, 6);

console.log(Atomics.load(uint8,0));
  • 0
  • 10
  • 6
  • 4

Quiz 18:

Q1. What is the correct output of the following code?

function func() {
  let promise = Promise.resolve(1);
  let result = await promise;
}
func();
  • 1
  • true
  • undefined
  • SyntaxError

Q2. What is the last output of the following code:

function walk(amount) {
  return new Promise((resolve,reject) => {
    if (amount > 500) {
      reject ("the value is too big");
    }
    setTimeout(() => resolve(`you walked for ${amount}ms`),amount);
  });
}

async function go() {
  const res = await walk(500);
  console.log(res);
  const res2 = await walk(300);
  console.log(res2);
  const res3 = await walk(200);
  console.log(res3);
  const res4 = await walk(700);
  console.log(res4);
  const res5 = await walk(400);
  console.log(res5);
  console.log("finished");
}

go();
  • “you walked for 700ms”
  • “you walked for 400ms”
  • uncaught exception: the value is too big
  • “finished”

Quiz 19:

Q1. What is the correct syntax for the spread operator for objects?

  • […]
  • (…)
  • {…}
  • =>

Q2. What is the correct output of the following code:

let myObj = {
  a:1,
  b:2,
  c:3,
  d:4,
}

let { a, b, ...z } = myObj;
console.log(z);
  • [3,4]
  • {c:3, d:4}
  • undefined
  • [c,d]

Q3. What is the correct output of the following code:

const myPromise = new Promise((resolve,reject) => {
  resolve();
})
myPromise
.then( () => {
    return '1';
  })
  .finally(()=> {
    return '2!';
  })
  .then( res => {
    console.log(res);
  })
  • 1
  • 2
  • 1,2

Quiz 20:

Q1. What is the correct output of the following code?

const me = Symbol("Alberto");
console.log(me.description);
  • Symbol
  • Symbol(Alberto)
  • “Alberto”
  • undefined

Q2. What is the correct output of the following code?

const letters = ['a', 'b', ['c', 'd', ['e', 'f']]];
console.log(letters.flat())
  • ['a', 'b', ['c', 'd', ['e', 'f']]]
  • ['a', 'b', 'c', 'd', 'e', 'f']
  • ['a', 'b', 'c', 'd', ['e', 'f']]
  • ['a', 'b', ['c', 'd', 'e', 'f']]

Q3. What is the correct output of the following code?

function sum(a, b) { return a + b }

console.log(sum.toString());
  • Function
  • “a + b”
  • sum
  • function sum(a, b) { return a + b; }

Quiz 21:

Q1. What is the correct output of the following code?

let bigInt = 99999999999999999;
console.log(bigInt + 1n);
  • 100000000000000000n
  • 99999999999999999
  • Uncaught TypeError: Cannot mix BigInt and other types, use explicit conversions
  • 100000000000000000

Q2. What is the correct output of the following code?

const user = {
 name: 'Alberto',
 age: 27,
 work: {
  title: 'software developer'
 }
}

const res = user?.work?.location ? user?.work?.location : user?.work?.title

console.log(res);
  • location
  • title
  • ‘software developer’
  • undefined

Q3. What is the correct output of the following code?


const x = 0;

const res = x ?? 'zero';
console.log(res);
  • 0
  • ‘zero’
  • undefined
  • null

Q4. What is the correct output of the following code?


const x = undefined;

const res = x ?? 'undefined value';
console.log(res);
  • ‘undefined value’
  • false
  • undefined
  • null

Q5. What does the globalThis object reference in a browser environment?

  • window
  • document
  • global
  • self

Quiz 22:

Q1. Which one of the following methods was introduced in ES2021

  • String.prototype.replace()
  • String.prototype.startsWith()
  • String.prototype.replaceAll()
  • String.prototype.substring()

Q2. Which one of the following methods were introduced in ES2021?

  • Promise.race()
  • Promise.every()
  • Promise.any()
  • Promise.all()

Q3. What is the correct output of the following code?

new Intl.ListFormat("en-GB", { style: "long", type: "conjunction" }).format(
  list
)
  • Apple and Orange and Banana
  • Apple, Orange, Banana
  • Apple, Orange and Banana
  • Apple, Orange or Banana

Q4. What is the correct output of this code?

new Intl.DateTimeFormat("en", {
  dateStyle: "short",
}).format(Date.now());
  • “7/25/20”
  • “Jul 25, 2020”
  • “July 25, 2020”
  • “25/7/20”

Quiz 23:

Q1. What is the character used to define private methods in ES2022?

  • private
  • @
  • #
  • *

Q2. Which one of these is valid for static methods?

  • They can be accessed only on new instances of a class
  • They can never be private
  • They can only be accessed on the prototype
  • They can be accessed both on the prototype and on new instances of a class

Q3. What is the new character used in RegExp to match indices?

  • i
  • o
  • g
  • d

Q4. What is the correct output of the following code?

const arr = [10,20,30,40];
console.log(arr.at(-2));
  • 10
  • 20
  • 30
  • 40

Q5. What is the correct output of the following code?

const student = {
    age:10;
   hasOwnProperty: () => {
       console.log(false)
   }
}

student.hasOwnProperty('age');
  • true
  • false
  • undefined

Quiz 24:

Q1. Which one of these is not a real basic type of TypeScript?

  • Tuple
  • void
  • enum
  • every

Q2. What is the correct type of the following variable?

const x = 0xf00d;
  • string
  • void
  • hex
  • number

Q3. Which of the following type definition is wrong?

  • const firstArray: number[] = [1,2,3]
  • const firstArray: Array<number> = [1,2,3]
  • const firstArray: number<Array> = [1,2,3]

Q4. What is the correct output of the following code?

enum Rank {first, second, third}

const myRank: Rank = Rank.second;
console.log(myRank);
  • “second”
  • {second:1}
  • true
  • 2
  • 1

Q5. What is the correct way of defining an Interface?

  • interface Car = { wheels: number }
  • interface Car { wheels = number }
  • interface Car { wheels: number }
  • interface Car = { wheels = number }
Conclusion:

I hope this The Complete Guide to Modern JavaScript Educative Quiz Answers would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

More Coding Solutions >>

LeetCode Solutions

Hacker Rank Solutions

CodeChef Solutions

Leave a Reply

Your email address will not be published.