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

Javob variantlari:
Anonymous Quiz
0%
A: "Lydia"
0%
B: "myName"
0%
C: undefined
100%
D: ReferenceError
77. Is this a pure function?

function sum(a, b) {
return a + b;
}
77. Is this a pure function?

Javob variantlari:
Anonymous Quiz
100%
A: Yes
0%
B: No
78. What is the output?

const add = () => {
const cache = {};
return num => {
if (num in cache) {
return `From cache! ${cache[num]}`;
} else {
const result = num + 10;
cache[num] = result;
return `Calculated! ${result}`;
}
};
};

const addFunction = add();
console.log(addFunction(10));
console.log(addFunction(10));
console.log(addFunction(5 * 2));
79. What is the output?

const myLifeSummedUp = ['β˜•οΈ', 'πŸ’»', '🍷', '🍫'];

for (let item in myLifeSummedUp) {
console.log(item);
}

for (let item of myLifeSummedUp) {
console.log(item);
}
80. What is the output?

const list = [1 + 2, 1 * 2, 1 / 2];
console.log(list);
81. What is the output?

function sayHi(name) {
return `Hi there, ${name}`;
}

console.log(sayHi());
82. What is the output?

var status = '😎';

setTimeout(() => {
const status = '😍';

const data = {
status: 'πŸ₯‘',
getStatus() {
return this.status;
},
};

console.log(data.getStatus());
console.log(data.getStatus.call(this));
}, 0);
83. What is the output?

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

let city = person.city;
city = 'Amsterdam';

console.log(person);
84. What is the output?

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));
85. What kind of information would get logged?

fetch('https://www.website.com/api/user/1')
.then(res => res.json())
.then(res => console.log(res));
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 = //
}
86. Which option is a way to set hasName equal to true, provided you cannot pass true as an argument?

Javob variantlari:
Anonymous Quiz
0%
A: !!name
100%
B: name
0%
C: new Boolean(name)
0%
D: name.length