Daily JavaScript
15 subscribers
1 photo
1 link
Daily examples, coding challenges, and useful tips for developers.
Download Telegram
116. What's the output?

const person = {
name: 'Lydia',
age: 21,
};

const changeAge = (x = { ...person }) => (x.age += 1);
const changeAgeAndName = (x = { ...person }) => {
x.age += 1;
x.name = 'Sarah';
};

changeAge(person);
changeAgeAndName();

console.log(person);
117. Which of the following options will return 6?

function sumValues(x, y, z) {
return x + y + z;
}
117. Which of the following options will return 6?

Javob variantlari:
Anonymous Quiz
0%
A: sumValues([...1, 2, 3])
0%
B: sumValues([...[1, 2, 3]])
0%
C: sumValues(...[1, 2, 3])
0%
D: sumValues([1, 2, 3])
118. What's the output?

let num = 1;
const list = ['🥳', '🤠', '🥰', '🤪'];

console.log(list[(num += 1)]);
118. What's the output?

Javob variantlari:
Anonymous Quiz
0%
A: 🤠
0%
B: 🥰
0%
C: SyntaxError
0%
D: ReferenceError
119. What's the output?

const person = {
firstName: 'Lydia',
lastName: 'Hallie',
pet: {
name: 'Mara',
breed: 'Dutch Tulip Hound',
},
getFullName() {
return `${this.firstName} ${this.lastName}`;
},
};

console.log(person.pet?.name);
console.log(person.pet?.family?.name);
console.log(person.getFullName?.());
console.log(member.getLastName?.());
120. What's the output?

const groceries = ['banana', 'apple', 'peanuts'];

if (groceries.indexOf('banana')) {
console.log('We have to buy bananas!');
} else {
console.log(`We don't have to buy bananas!`);
}
121. What's the output?

const config = {
languages: [],
set language(lang) {
return this.languages.push(lang);
},
};

console.log(config.language);
122. What's the output?

const name = 'Lydia Hallie';

console.log(!typeof name === 'object');
console.log(!typeof name === 'string');
122. What's the output?

Javob variantlari:
Anonymous Quiz
0%
A: false true
0%
B: true false
0%
C: false false
0%
D: true true
123. What's the output?


const add = x => y => z => {
console.log(x, y, z);
return x + y + z;
};

add(4)(5)(6);
123. What's the output?

Javob variantlari:
Anonymous Quiz
0%
A: 4 5 6
0%
B: 6 5 4
0%
C: 4 function function
0%
D: undefined undefined 6
124. What's the output?

async function* range(start, end) {
for (let i = start; i <= end; i++) {
yield Promise.resolve(i);
}
}

(async () => {
const gen = range(1, 3);
for await (const item of gen) {
console.log(item);
}
})();
125. What's the output?

const myFunc = ({ x, y, z }) => {
console.log(x, y, z);
};

myFunc(1, 2, 3);