Daily JavaScript
15 subscribers
1 photo
1 link
Daily examples, coding challenges, and useful tips for developers.
Download Telegram
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);
126. What's the output?

function getFine(speed, amount) {
const formattedSpeed = new Intl.NumberFormat('en-US', {
style: 'unit',
unit: 'mile-per-hour'
}).format(speed);

const formattedAmount = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD'
}).format(amount);

return `The driver drove ${formattedSpeed} and has to pay ${formattedAmount}`;
}

console.log(getFine(130, 300))
127. What's the output?

const spookyItems = ['👻', '🎃', '🕸'];
({ item: spookyItems[3] } = { item: '💀' });

console.log(spookyItems);
128. What's the output?

const name = 'Lydia Hallie';
const age = 21;

console.log(Number.isNaN(name));
console.log(Number.isNaN(age));

console.log(isNaN(name));
console.log(isNaN(age));
129. What's the output?

const randomValue = 21;

function getInfo() {
console.log(typeof randomValue);
const randomValue = 'Lydia Hallie';
}

getInfo();
129. What's the output?

Javob variantlari:
Anonymous Quiz
0%
A: "number"
0%
B: "string"
0%
C: undefined
100%
D: ReferenceError