const fetchData = async (id) => {
return new Promise((resolve) => {
setTimeout(() => resolve(`Data for ID ${id}`), 100);
});
};
const ids = [1, 2, 3];
async function complexAsyncFetch(ids) {
const result = await ids.reduce(async (acc, id) => {
const data = await fetchData(id);
const currentResult = await acc;
currentResult.push(data);
return currentResult;
}, Promise.resolve([]));
console.log(result);
}
complexAsyncFetch(ids);
Please open Telegram to view this post
VIEW IN TELEGRAM
β€5
Please open Telegram to view this post
VIEW IN TELEGRAM
π€£71π12 11β€3π€©3π€1
function recursiveFibonacci(n) {
return n <= 1 ? n : recursiveFibonacci(n - 1) + recursiveFibonacci(n - 2);
}
const result = recursiveFibonacci(6);
console.log(result);
Please open Telegram to view this post
VIEW IN TELEGRAM
π9
π€16 8β€5π5
Please open Telegram to view this post
VIEW IN TELEGRAM
π€£107π10β€4 3
function recursivePalindromeCheck(str) {
if (str.length <= 1) {
return true;
}
return str[0] === str[str.length - 1] && recursivePalindromeCheck(str.slice(1, -1));
}
const result = recursivePalindromeCheck("radar");
console.log(result);
Please open Telegram to view this post
VIEW IN TELEGRAM
What is the output?
Anonymous Quiz
59%
true
24%
false
9%
This will result in an error.
8%
The output is not predictable.
π9 5β€3π€3
Please open Telegram to view this post
VIEW IN TELEGRAM
π14π€©3 3β€2π€2
function recursiveBinarySearch(arr, target, start = 0, end = arr.length - 1) {
if (start > end) {
return -1;
}
const mid = Math.floor((start + end) / 2);
if (arr[mid] === target) {
return mid;
} else if (arr[mid] < target) {
return recursiveBinarySearch(arr, target, mid + 1, end);
} else {
return recursiveBinarySearch(arr, target, start, mid - 1);
}
}
const result = recursiveBinarySearch([1, 2, 3, 4, 5, 6, 7, 8, 9], 6);
console.log(result);
Please open Telegram to view this post
VIEW IN TELEGRAM
β€12π1
π€9π8 6π€£4β€3π€©2
Taking the manual, 'do it all by hand' approach. A good way to learn about all the pieces involved before automating it, perhaps.
SAM MEECH-WARD
Please open Telegram to view this post
VIEW IN TELEGRAM
β€9π4 2
function recursiveReverseString(str) {
return str === "" ? str : recursiveReverseString(str.substr(1)) + str[0];
}
const result = recursiveReverseString("hello");
console.log(result);
Please open Telegram to view this post
VIEW IN TELEGRAM
π€19π12 7β€6π€©4
const obj = {
0: 'a',
1: 'b',
length: 2
};
const result = Array.from(obj);
console.log(result);
Please open Telegram to view this post
VIEW IN TELEGRAM
What is the output?
Anonymous Quiz
32%
[βaβ, βbβ]
42%
[βaβ, βbβ, 2]
6%
[2, βaβ, βbβ]
20%
[0, 1, βlengthβ]
π€28β€10π7π€£6 6
Please open Telegram to view this post
VIEW IN TELEGRAM
π€26β€17 7π€©2
10K strong in under a year! β‘οΈ
Thanks to your incredible support, we're aiming for 100K next!π This isn't a dream β it's our plan in action! πͺ
Varik, Sipan, Nairi
βοΈ Check out our emoji pack here
βοΈ Boost us in Telegram
π€ Collaboration
Thanks to your incredible support, we're aiming for 100K next!
Varik, Sipan, Nairi
Please open Telegram to view this post
VIEW IN TELEGRAM
β€34π11 7π€©3π€2π€£1
Paul Scanlon compares React to Qwik using several examples and concludes that Qwik is at least worth exploring as a React alternative.
PAUL SCANLON
Please open Telegram to view this post
VIEW IN TELEGRAM
π5 5β€3
function* generatorQuiz() {
yield 1;
}
const generator = generatorQuiz();
setTimeout(() => console.log(generator.next().value), 0);
for (const value of generator) {
console.log(value);
}
Please open Telegram to view this post
VIEW IN TELEGRAM