CHALLENGE
async function fetchData() {
console.log('1');
return Promise.resolve('data');
}
async function processData() {
console.log('2');
const result = await fetchData();
console.log('3');
return result;
}
console.log('4');
processData().then(() => console.log('5'));
console.log('6');
β€4π2π€2
Describing itself as βa fancy cron replacementβ, Cronicle is a distributed task scheduler and runner, built around a Node app with a web based UI. GitHub repo.
Joseph Huckaby
Please open Telegram to view this post
VIEW IN TELEGRAM
β€5π5π₯1
CHALLENGE
const arr = new Array(1000000).fill(0).map((_, i) => i);
const results = [];
function method1() {
return arr.filter(x => x % 2 === 0).map(x => x * 2).slice(0, 3);
}
function method2() {
const result = [];
for (let i = 0; i < arr.length && result.length < 3; i++) {
if (arr[i] % 2 === 0) {
result.push(arr[i] * 2);
}
}
return result;
}
console.log(method1().join(','));
console.log(method2().join(','));
β€1π1π₯1
Please open Telegram to view this post
VIEW IN TELEGRAM
β€6π3π₯1
CHALLENGE
const obj = { a: 1, b: { c: 2 } };
const frozen = Object.freeze(obj);
frozen.a = 99;
frozen.b.c = 88;
frozen.d = 77;
const sealed = Object.seal({ x: 10, y: 20 });
sealed.x = 30;
sealed.z = 40;
delete sealed.y;
console.log(obj.a, obj.b.c, obj.d);
console.log(sealed.x, sealed.y, sealed.z);
What is the output?
Anonymous Quiz
25%
99 88 77, 30 20 40
48%
1 88 undefined, 30 20 undefined
20%
1 2 undefined, 10 20 undefined
6%
99 2 77, 30 undefined 40
β€4π1π₯1