js-up-quiz
js-up-quiz
function sayHi() {
console.log(name);
console.log(age);
var name = ‘Lydia’;
let age = 21;
}
sayHi();
Answer D
A: 0 1 2 and 0 1 2
B: 0 1 2 and 3 3 3
C: 3 3 3 and 0 1 2
Answer C
const shape = {
radius: 10,
diameter() {
return this.radius * 2;
https://stackedit.io/app# 1/78
11/21/24, 2:30 AM StackEdit
},
perimeter: () => 2 * Math.PI * this.radius,
};
console.log(shape.diameter());
console.log(shape.perimeter());
A: 20 and 62.83185307179586
B: 20 and NaN
C: 20 and 63
D: NaN and 63
Answer B
+true;
!‘Lydia’;
A: 1 and false
B: false and NaN
C: false and false
Answer A
const bird = {
size: ‘small’,
};
const mouse = {
name: ‘Mickey’,
small: true,
};
https://stackedit.io/app# 2/78
11/21/24, 2:30 AM StackEdit
Answer A
d = c;
c.greeting = ‘Hello’;
console.log(d.greeting);
A: Hello
B: Hey!
C: undefined
D: ReferenceError
E: TypeError
Answer A
let a = 3;
let b = new Number(3);
https://stackedit.io/app# 3/78
11/21/24, 2:30 AM StackEdit
let c = 3;
console.log(a == b);
console.log(a === b);
console.log(b === c);
Answer C
class Chameleon {
static colorChange(newColor) {
this.newColor = newColor;
return this.newColor;
}
A: orange
B: purple
C: green
D: TypeError
Answer D
https://stackedit.io/app# 4/78
11/21/24, 2:30 AM StackEdit
let greeting;
greetign = {}; // Typo!
console.log(greetign);
A: {}
B: ReferenceError: greetign is not defined
C: undefined
Answer A
function bark() {
console.log(‘Woof!’);
}
bark.animal = ‘dog’;
Answer D
console.log(member.getFullName());
A: TypeError
https://stackedit.io/app# 5/78
11/21/24, 2:30 AM StackEdit
B: SyntaxError
C: Lydia Hallie
D: undefined undefined
Answer D
console.log(lydia);
console.log(sarah);
Answer D
Answer D
https://stackedit.io/app# 6/78
11/21/24, 2:30 AM StackEdit
A: true
B: false
Answer A
function sum(a, b) {
return a + b;
}
sum(1, ‘2’);
A: NaN
B: TypeError
C: "12"
D: 3
Answer C
let number = 0;
console.log(number++);
https://stackedit.io/app# 7/78
11/21/24, 2:30 AM StackEdit
console.log(++number);
console.log(number);
A: 1 1 2
B: 1 2 2
C: 0 2 2
D: 0 1 2
Answer C
Answer A
function checkAge(data) {
if (data === { age: 18 }) {
console.log(‘You are an adult!’);
} else if (data == { age: 18 }) {
console.log(‘You are still an adult.’);
} else {
console.log( Hmm.. You don't have an age I guess );
https://stackedit.io/app# 8/78
11/21/24, 2:30 AM StackEdit
}
}
Answer B
function getAge(…args) {
console.log(typeof args);
}
getAge(21);
A: "number"
B: "array"
C: "object"
D: "NaN"
Answer A
function getAge() {
‘use strict’;
age = 21;
console.log(age);
}
getAge();
A: 21
B: undefined
C: ReferenceError
D: TypeError
https://stackedit.io/app# 9/78
11/21/24, 2:30 AM StackEdit
Answer C
A: 105
B: "105"
C: TypeError
D: "10*10+5"
Answer A
sessionStorage.setItem(‘cool_secret’, 123);
Answer C
var num = 8;
var num = 10;
console.log(num);
A: 8
B: 10
C: SyntaxError
D: ReferenceError
Answer B
https://stackedit.io/app# 10/78
11/21/24, 2:30 AM StackEdit
24. What’s the output?
obj.hasOwnProperty(‘1’);
obj.hasOwnProperty(1);
set.has(‘1’);
set.has(1);
Answer A
A: { a: "one", b: "two" }
B: { b: "two", a: "three" }
C: { a: "three", b: "two" }
D: SyntaxError
Answer B
26. The JavaScript global execution context creates two things for you: the global object, and the “this” keyword.
A: true
B: false
C: it depends
Answer A
https://stackedit.io/app# 11/78
11/21/24, 2:30 AM StackEdit
A: 1 2
B: 1 2 3
C: 1 2 4
D: 1 3 4
Answer C
String.prototype.giveLydiaPizza = () => {
return ‘Just give Lydia pizza already!’;
};
console.log(name.giveLydiaPizza())
Answer A
const a = {};
const b = { key: ‘b’ };
const c = { key: ‘c’ };
a[b] = 123;
a[c] = 456;
console.log(a[b]);
https://stackedit.io/app# 12/78
11/21/24, 2:30 AM StackEdit
A: 123
B: 456
C: undefined
D: ReferenceError
Answer A
bar();
foo();
baz();
Answer B
https://stackedit.io/app# 13/78
11/21/24, 2:30 AM StackEdit
https://stackedit.io/app# 14/78
11/21/24, 2:30 AM StackEdit
https://stackedit.io/app# 15/78
11/21/24, 2:30 AM StackEdit
https://stackedit.io/app# 16/78
11/21/24, 2:30 AM StackEdit
https://stackedit.io/app# 17/78
11/21/24, 2:30 AM StackEdit
Click!
A: Outer div
B: Inner div
C: button
D: An array of all nested elements.
Answer C
32. When you click the paragraph, what’s the logged output?
Click here!
https://stackedit.io/app# 18/78
11/21/24, 2:30 AM StackEdit
A: p div
B: div p
C: p
D: div
Answer A
function sayHi(age) {
return ${this.name} is ${age} ;
}
console.log(sayHi.call(person, 21));
console.log(sayHi.bind(person, 21));
A: undefined is 21 Lydia is 21
B: function function
C: Lydia is 21 Lydia is 21
D: Lydia is 21 function
Answer D
function sayHi() {
return (() => 0)();
}
console.log(typeof sayHi());
A: "object"
B: "number"
C: "function"
D: "undefined"
Answer A
https://stackedit.io/app# 19/78
11/21/24, 2:30 AM StackEdit
0;
new Number(0);
(’’);
(’ ');
new Boolean(false);
undefined;
A: 0 , '' , undefined
B: 0 , new Number(0) , '' , new Boolean(false) , undefined
C: 0 , '' , new Boolean(false) , undefined
D: All of them are falsy
Answer B
A: "number"
B: "string"
C: "object"
D: "undefined"
Answer B
Answer A
https://stackedit.io/app# 20/78
11/21/24, 2:30 AM StackEdit
(() => {
let x, y;
try {
throw new Error();
} catch (x) {
(x = 1), (y = 2);
console.log(x);
}
console.log(x);
console.log(y);
})();
A: 1 undefined 2
B: undefined undefined undefined
C: 1 1 2
D: 1 undefined undefined
Answer NA
A: primitive or object
B: function or object
C: trick question! only objects
D: number or object
Answer C
A: [0, 1, 2, 3, 1, 2]
B: [6, 1, 2]
C: [1, 2, 0, 1, 2, 3]
D: [1, 2, 6]
Answer C
!!null;
!!’’;
!!1;
Answer B
A: a unique id
B: the amount of milliseconds specified
C: the passed function
D: undefined
Answer C
[…‘Lydia’];
https://stackedit.io/app# 22/78
11/21/24, 2:30 AM StackEdit
Answer A
function* generator(i) {
yield i;
yield i * 2;
}
console.log(gen.next().value);
console.log(gen.next().value);
Answer NA
A: "one"
B: "two"
C: "two" "one"
D: "one" "two"
https://stackedit.io/app# 23/78
11/21/24, 2:30 AM StackEdit
Answer B
console.log(members);
A: null
B: [null]
C: [{}]
D: [{ name: "Lydia" }]
Answer B
https://stackedit.io/app# 24/78
11/21/24, 2:30 AM StackEdit
const person = {
name: ‘Lydia’,
age: 21,
};
https://stackedit.io/app# 25/78
11/21/24, 2:30 AM StackEdit
C: "Lydia", 21
D: ["name", "Lydia"], ["age", 21]
Answer C
console.log(3 + 4 + ‘5’);
A: "345"
B: "75"
C: 12
D: "12"
Answer C
A: 42
B: "42"
C: 7
D: NaN
Answer A
A: []
B: [null, null, null]
C: [undefined, undefined, undefined]
D: [ 3 x empty ]
https://stackedit.io/app# 26/78
11/21/24, 2:30 AM StackEdit
Answer C
getInfo(person, birthYear);
console.log(person, birthYear);
Answer
function greeting() {
throw ‘Hello world!’;
}
function sayHi() {
try {
const data = greeting();
console.log(‘It worked!’, data);
} catch (e) {
console.log(‘Oh no an error:’, e);
}
}
sayHi();
https://stackedit.io/app# 27/78
11/21/24, 2:30 AM StackEdit
Answer
function Car() {
this.make = ‘Lamborghini’;
return { make: ‘Maserati’ };
}
A: "Lamborghini"
B: "Maserati"
C: ReferenceError
D: TypeError
Answer
(() => {
let x = (y = 10);
})();
console.log(typeof x);
console.log(typeof y);
A: "undefined", "number"
B: "number", "number"
C: "object", "number"
D: "number", "undefined"
Answer
https://stackedit.io/app# 28/78
11/21/24, 2:30 AM StackEdit
class Dog {
constructor(name) {
this.name = name;
}
}
Dog.prototype.bark = function() {
console.log( Woof I am ${this.name} );
};
pet.bark();
delete Dog.prototype.bark;
pet.bark();
Answer
console.log(set);
A: [1, 1, 2, 3, 4]
B: [1, 2, 3, 4]
C: {1, 1, 2, 3, 4}
D: {1, 2, 3, 4}
Answer
https://stackedit.io/app# 29/78
11/21/24, 2:30 AM StackEdit
57. What’s the output?
// counter.js
let counter = 10;
export default counter;
// index.js
import myCounter from ‘./counter’;
myCounter += 1;
console.log(myCounter);
A: 10
B: 11
C: Error
D: NaN
Answer
console.log(delete name);
console.log(delete age);
A: false , true
B: "Lydia" , 21
C: true , true
D: undefined , undefined
Answer
console.log(y);
https://stackedit.io/app# 30/78
11/21/24, 2:30 AM StackEdit
A: [[1, 2, 3, 4, 5]]
B: [1, 2, 3, 4, 5]
C: 1
D: [1]
Answer
console.log(admin);
Answer
console.log(person);
console.log(Object.keys(person));
Answer
https://stackedit.io/app# 31/78
11/21/24, 2:30 AM StackEdit
const settings = {
username: ‘lydiahallie’,
level: 19,
health: 90,
};
A: "{"level":19, "health":90}"
B: "{"username": "lydiahallie"}"
C: "["level", "health"]"
D: "{"username": "lydiahallie", "level":19, "health":90}"
Answer
console.log(num1);
console.log(num2);
A: 10 , 10
B: 10 , 11
C: 11 , 11
D: 11 , 12
Answer
https://stackedit.io/app# 32/78
11/21/24, 2:30 AM StackEdit
multiply();
multiply();
multiply(value);
multiply(value);
A: 20 , 40 , 80 , 160
B: 20 , 40 , 20 , 40
C: 20 , 20 , 20 , 40
D: NaN , NaN , 20 , 40
Answer
A: 1 2 and 3 3 and 6 4
B: 1 2 and 2 3 and 3 4
C: 1 undefined and 2 undefined and 3 undefined and 4 undefined
D: 1 2 and undefined 3 and undefined 4
Answer
66. With which constructor can we successfully extend the Dog class?
class Dog {
constructor(name) {
this.name = name;
}
};
https://stackedit.io/app# 33/78
11/21/24, 2:30 AM StackEdit
}
// 2
constructor(name, size) {
super(name);
this.size = size;
}
// 3
constructor(size) {
super(name);
this.size = size;
}
// 4
constructor(name, size) {
this.name = name;
this.size = size;
}
};
A: 1
B: 2
C: 3
D: 4
Answer
// index.js
console.log(‘running index.js’);
import { sum } from ‘./sum.js’;
console.log(sum(1, 2));
// sum.js
console.log(‘running sum.js’);
export const sum = (a, b) => a + b;
https://stackedit.io/app# 34/78
11/21/24, 2:30 AM StackEdit
Answer
Answer
Answer
console.log(‘🥑’ + ‘💻’);
A: "🥑💻"
https://stackedit.io/app# 35/78
11/21/24, 2:30 AM StackEdit
B: 257548
C: A string containing their code points
D: Error
Answer
71. How can we log the values that are commented out after the console.log statement?
function* startGame() {
const answer = yield ‘Do you love JavaScript?’;
if (answer !== ‘Yes’) {
return “Oh wow… Guess we’re done here”;
}
return ‘JavaScript loves you back ❤️’;
}
Answer
console.log(String.raw Hello\nworld );
A: Hello world!
B: Hello
world
C: Hello\nworld
D: Hello\n
world
Answer
https://stackedit.io/app# 36/78
11/21/24, 2:30 AM StackEdit
Answer
A: ['apple', 'banana']
B: 2
C: true
D: undefined
Answer
Object.freeze(box);
https://stackedit.io/app# 37/78
11/21/24, 2:30 AM StackEdit
console.log(shape);
A: { x: 100, y: 20 }
B: { x: 10, y: 20 }
C: { x: 100 }
D: ReferenceError
Answer
console.log(firstName);
A: "Lydia"
B: "myName"
C: undefined
D: ReferenceError
Answer
function sum(a, b) {
return a + b;
}
A: Yes
B: No
Answer
https://stackedit.io/app# 38/78
11/21/24, 2:30 AM StackEdit
Answer
Answer
Answer
function sayHi(name) {
return Hi there, ${name} ;
}
console.log(sayHi());
A: Hi there,
B: Hi there, undefined
C: Hi there, null
D: ReferenceError
Answer
setTimeout(() => {
const status = ‘😍’;
https://stackedit.io/app# 40/78
11/21/24, 2:30 AM StackEdit
const data = {
status: ‘🥑’,
getStatus() {
return this.status;
},
};
console.log(data.getStatus());
console.log(data.getStatus.call(this));
}, 0);
Answer
const person = {
name: ‘Lydia’,
age: 21,
};
console.log(person);
Answer
https://stackedit.io/app# 41/78
11/21/24, 2:30 AM StackEdit
function checkAge(age) {
if (age < 18) {
const message = “Sorry, you’re too young.”;
} else {
const message = “Yay! You’re old enough!”;
}
return message;
}
console.log(checkAge(21));
Answer
fetch(‘https://www.website.com/api/user/1’)
.then(res => res.json())
.then(res => console.log(res));
Answer
86. Which option is a way to set hasName equal to true , provided you cannot pass true as an argument?
function getName(name) {
const hasName = //
}
A: !!name
https://stackedit.io/app# 42/78
11/21/24, 2:30 AM StackEdit
B: name
C: new Boolean(name)
D: name.length
Answer
A: """
B: "I"
C: SyntaxError
D: undefined
Answer
sum(10);
A: NaN
B: 20
C: ReferenceError
D: undefined
Answer
// module.js
export default () => ‘Hello world’;
export const name = ‘Lydia’;
https://stackedit.io/app# 43/78
11/21/24, 2:30 AM StackEdit
// index.js
import * as data from ‘./module’;
console.log(data);
Answer
class Person {
constructor(name) {
this.name = name;
}
}
A: "class"
B: "function"
C: "object"
D: "string"
Answer
console.log(newList.push(5));
A: [1, 2, 3, 4, 5]
B: [1, 2, 3, 5]
C: [1, 2, 3, 4]
D: Error
https://stackedit.io/app# 44/78
11/21/24, 2:30 AM StackEdit
Answer
function giveLydiaPizza() {
return ‘Here is pizza!’;
}
console.log(giveLydiaPizza.prototype);
console.log(giveLydiaChocolate.prototype);
Answer
const person = {
name: ‘Lydia’,
age: 21,
};
Answer
https://stackedit.io/app# 45/78
11/21/24, 2:30 AM StackEdit
94. What’s the output?
Answer
function nums(a, b) {
if (a > b) console.log(‘a is bigger’);
else console.log(‘b is bigger’);
return
a + b;
}
console.log(nums(4, 2));
console.log(nums(1, 2));
Answer
class Person {
constructor() {
this.name = ‘Lydia’;
https://stackedit.io/app# 46/78
11/21/24, 2:30 AM StackEdit
}
}
A: "Lydia"
B: "Sarah"
C: Error: cannot redeclare Person
D: SyntaxError
Answer
const info = {
[Symbol(‘a’)]: ‘b’,
};
console.log(info);
console.log(Object.keys(info));
Answer
https://stackedit.io/app# 47/78
11/21/24, 2:30 AM StackEdit
console.log(getList(list))
console.log(getUser(user))
Answer
console.log(name());
A: SyntaxError
B: ReferenceError
C: TypeError
D: undefined
Answer
const output = ${[] && 'Im'}possible! You should${'' && n’t } see a therapist
after so much JavaScript lol ;
https://stackedit.io/app# 48/78
11/21/24, 2:30 AM StackEdit
Answer
A: false null []
B: null "" true
C: {} "" []
D: null null true
Answer
function firstFunction() {
myPromise().then(res => console.log(res));
console.log(‘second’);
}
firstFunction();
secondFunction();
Answer
https://stackedit.io/app# 49/78
11/21/24, 2:30 AM StackEdit
set.add(1);
set.add(‘Lydia’);
set.add({ name: ‘Lydia’ });
A: 3 , NaN , NaN
B: 3 , 7 , NaN
C: 3 , Lydia2 , [object Object]2
D: "12" , Lydia2 , [object Object]2
Answer
Promise.resolve(5);
A: 5
B: Promise {<pending>: 5}
C: Promise {<fulfilled>: 5}
D: Error
Answer
compareMembers(person);
Answer
const colorConfig = {
red: true,
blue: false,
green: true,
black: true,
yellow: false,
};
console.log(colorConfig.colors[1]);
A: true
B: false
C: undefined
D: TypeError
Answer
A: true
B: false
Answer
https://stackedit.io/app# 51/78
11/21/24, 2:30 AM StackEdit
A: All of them
B: map reduce slice splice
C: map slice splice
D: splice
Answer
info.favoriteFood = ‘🍝’;
console.log(food);
Answer
JSON.parse();
https://stackedit.io/app# 52/78
11/21/24, 2:30 AM StackEdit
Answer
function getName() {
console.log(name);
let name = ‘Sarah’;
}
getName();
A: Lydia
B: Sarah
C: undefined
D: ReferenceError
Answer
function* generatorOne() {
yield [‘a’, ‘b’, ‘c’];
}
function* generatorTwo() {
yield* [‘a’, ‘b’, ‘c’];
}
console.log(one.next().value);
console.log(two.next().value);
https://stackedit.io/app# 53/78
11/21/24, 2:30 AM StackEdit
A: a and a
B: a and undefined
C: ['a', 'b', 'c'] and a
D: a and ['a', 'b', 'c']
Answer
A: I love to program
B: undefined to program
C: ${(x => x)('I love') to program
D: TypeError
Answer
let config = {
alert: setInterval(() => {
console.log(‘Alert!’);
}, 1000),
};
config = null;
Answer
https://stackedit.io/app# 54/78
11/21/24, 2:30 AM StackEdit
//1
myMap.get(‘greeting’);
//2
myMap.get(myFunc);
//3
myMap.get(() => ‘greeting’);
A: 1
B: 2
C: 2 and 3
D: All of them
Answer
const person = {
name: ‘Lydia’,
age: 21,
};
changeAge(person);
changeAgeAndName();
console.log(person);
https://stackedit.io/app# 55/78
11/21/24, 2:30 AM StackEdit
Answer
function sumValues(x, y, z) {
return x + y + z;
}
A: sumValues([...1, 2, 3])
B: sumValues([...[1, 2, 3]])
C: sumValues(...[1, 2, 3])
D: sumValues([1, 2, 3])
Answer
let num = 1;
const list = [‘🥳’, ‘🤠’, ‘🥰’, ‘🤪’];
console.log(list[(num += 1)]);
A: 🤠
B: 🥰
C: SyntaxError
D: ReferenceError
Answer
const person = {
firstName: ‘Lydia’,
lastName: ‘Hallie’,
pet: {
name: ‘Mara’,
https://stackedit.io/app# 56/78
11/21/24, 2:30 AM StackEdit
console.log(person.pet?.name);
console.log(person.pet?.family?.name);
console.log(person.getFullName?.());
console.log(member.getLastName?.());
Answer
if (groceries.indexOf(‘banana’)) {
console.log(‘We have to buy bananas!’);
} else {
console.log( We don't have to buy bananas! );
}
Answer
https://stackedit.io/app# 57/78
11/21/24, 2:30 AM StackEdit
const config = {
languages: [],
set language(lang) {
return this.languages.push(lang);
},
};
console.log(config.language);
Answer
A: false true
B: true false
C: false false
D: true true
Answer
add(4)(5)(6);
A: 4 5 6
https://stackedit.io/app# 58/78
11/21/24, 2:30 AM StackEdit
B: 6 5 4
C: 4 function function
D: undefined undefined 6
Answer
(async () => {
const gen = range(1, 3);
for await (const item of gen) {
console.log(item);
}
})();
Answer
myFunc(1, 2, 3);
A: 1 2 3
B: {1: 1} {2: 2} {3: 3}
C: { 1: undefined } undefined undefined
https://stackedit.io/app# 59/78
11/21/24, 2:30 AM StackEdit
Answer
console.log(getFine(130, 300))
Answer
console.log(spookyItems);
Answer
console.log(Number.isNaN(name));
console.log(Number.isNaN(age));
console.log(isNaN(name));
console.log(isNaN(age));
Answer
function getInfo() {
console.log(typeof randomValue);
const randomValue = ‘Lydia Hallie’;
}
getInfo();
A: "number"
B: "string"
C: undefined
D: ReferenceError
Answer
https://stackedit.io/app# 61/78
11/21/24, 2:30 AM StackEdit
(async () => {
try {
console.log(await myPromise);
} catch {
throw new Error( Oops didn't work );
} finally {
console.log(‘Oh finally!’);
}
})();
Answer
console.log(emojis.flat(1));
Answer
class Counter {
constructor() {
this.count = 0;
}
https://stackedit.io/app# 62/78
11/21/24, 2:30 AM StackEdit
increment() {
this.count++;
}
}
console.log(counterOne.count);
A: 0
B: 1
C: 2
D: 3
Answer
function funcOne() {
setTimeout(() => console.log(‘Timeout 1!’), 0);
myPromise.then(res => res).then(res => console.log( ${res} 1! ));
console.log(‘Last line 1!’);
}
funcOne();
funcTwo();
https://stackedit.io/app# 63/78
11/21/24, 2:30 AM StackEdit
Answer
// sum.js
export default function sum(x) {
return x + x;
}
// index.js
import * as sum from ‘./sum’;
A: sum(4)
B: sum.sum(4)
C: sum.default(4)
D: Default aren’t imported with * , only named exports
Answer
const handler = {
set: () => console.log(‘Added a new property!’),
get: () => console.log(‘Accessed a property!’),
};
person.name = ‘Lydia’;
person.name;
https://stackedit.io/app# 64/78
11/21/24, 2:30 AM StackEdit
Answer
Object.seal(person);
Answer
const person = {
name: ‘Lydia Hallie’,
address: {
street: ‘100 Main St’,
},
};
Object.freeze(person);
Answer
https://stackedit.io/app# 65/78
11/21/24, 2:30 AM StackEdit
138. What’s the output?
myFunc();
myFunc(3);
A: 2 4 and 3 6
B: 2 NaN and 3 NaN
C: 2 Error and 3 6
D: 2 4 and 3 Error
Answer
class Counter {
#number = 10
increment() {
this.#number++
}
getNum() {
return this.#number
}
}
console.log(counter.#number)
A: 10
B: 11
C: undefined
D: SyntaxError
https://stackedit.io/app# 66/78
11/21/24, 2:30 AM StackEdit
Answer
const teams = [
{ name: ‘Team 1’, members: [‘Paul’, ‘Lisa’] },
{ name: ‘Team 2’, members: [‘Laura’, ‘Tim’] },
];
function* getMembers(members) {
for (let i = 0; i < members.length; i++) {
yield members[i];
}
}
function* getTeams(teams) {
for (let i = 0; i < teams.length; i++) {
// ✨ SOMETHING IS MISSING HERE ✨
}
}
A: yield getMembers(teams[i].members)
B: yield* getMembers(teams[i].members)
C: return getMembers(teams[i].members)
D: return yield getMembers(teams[i].members)
Answer
const person = {
name: ‘Lydia Hallie’,
hobbies: [‘coding’],
};
https://stackedit.io/app# 67/78
11/21/24, 2:30 AM StackEdit
addHobby(‘running’, []);
addHobby(‘dancing’);
addHobby(‘baking’, person.hobbies);
console.log(person.hobbies);
A: ["coding"]
B: ["coding", "dancing"]
C: ["coding", "dancing", "baking"]
D: ["coding", "running", "dancing", "baking"]
Answer
class Bird {
constructor() {
console.log(“I’m a bird. 🦢”);
}
}
A: I'm pink. 🌸
B: I'm pink. 🌸 I'm a bird. 🦢
C: I'm a bird. 🦢 I'm pink. 🌸
D: Nothing, we didn’t call any method
https://stackedit.io/app# 68/78
11/21/24, 2:30 AM StackEdit
Answer
/* 1 / emojis.push(‘🦌’);
/ 2 / emojis.splice(0, 2);
/ 3 / emojis = […emojis, ‘🥂’];
/ 4 */ emojis.length = 0;
A: 1
B: 1 and 2
C: 3 and 4
D: 3
Answer
144. What do we need to add to the person object to get ["Lydia Hallie", 21] as the output of [...person] ?
const person = {
name: “Lydia Hallie”,
age: 21
}
Answer
let count = 0;
const nums = [0, 1, 2, 3];
https://stackedit.io/app# 69/78
11/21/24, 2:30 AM StackEdit
nums.forEach(num => {
if (num) count += 1
})
console.log(count)
A: 1
B: 2
C: 3
D: 4
Answer
function getFruit(fruits) {
console.log(fruits?.[1]?.[1])
}
A: null , undefined , 🍌
B: [] , null , 🍌
C: [] , [] , 🍌
D: undefined , undefined , 🍌
Answer
class Calc {
constructor() {
this.count = 0
}
increase() {
this.count++
https://stackedit.io/app# 70/78
11/21/24, 2:30 AM StackEdit
console.log(calc.count)
A: 0
B: 1
C: undefined
D: ReferenceError
Answer
const user = {
email: "[email protected]",
password: “12345”
}
if (password) {
user.password = password
}
return user
A: false
https://stackedit.io/app# 71/78
11/21/24, 2:30 AM StackEdit
B: true
C: TypeError
D: ReferenceError
Answer
fruit.slice(0, 1)
fruit.splice(0, 1)
fruit.unshift(‘🍇’)
console.log(fruit)
Answer
console.log(animals[dog])
Answer
https://stackedit.io/app# 72/78
11/21/24, 2:30 AM StackEdit
const user = {
email: "[email protected]",
updateEmail: email => {
this.email = email
}
}
user.updateEmail("[email protected]")
console.log(user.email)
A: [email protected]
B: [email protected]
C: undefined
D: ReferenceError
Answer
runPromises()
.then(res => console.log(res))
.catch(err => console.log(err))
https://stackedit.io/app# 73/78
11/21/24, 2:30 AM StackEdit
D: 'Third'
Answer
153. What should the value of method be to log { name: "Lydia", age: 22 } ?
const method = /* ?? */
Object[method](keys.map((_, i) => {
return [keys[i], values[i]]
})) // { name: “Lydia”, age: 22 }
A: entries
B: values
C: fromEntries
D: forEach
Answer
return {
email,
address: address ? address : null
}
Answer
Answer
About
Resources
Readme
License
MIT license
Activity
Stars
https://stackedit.io/app# 75/78
11/21/24, 2:30 AM StackEdit
63k stars
Watchers
1.3k watching
Forks
8.9k forks
Report repository
Releases
No releases published
Packages
No packages published
Contributors205
https://stackedit.io/app# 76/78
11/21/24, 2:30 AM StackEdit
+ 191 contributors
Footer
Footer navigation
Terms
https://stackedit.io/app# 77/78
11/21/24, 2:30 AM StackEdit
Privacy
Security
Status
Docs
Contact
Manage cookies
Do not share my personal information
https://stackedit.io/app# 78/78