Skip to content

Instantly share code, notes, and snippets.

@az67128
Created July 28, 2020 13:11
Show Gist options
  • Save az67128/3cde673aa99d1798c69872f8bc927439 to your computer and use it in GitHub Desktop.
Save az67128/3cde673aa99d1798c69872f8bc927439 to your computer and use it in GitHub Desktop.
// Напишите функцию sum, которая бы работала следующим образом:
sum(1)(2) == 3; // 1 + 2
sum(1)(2)(3) == 6; // 1 + 2 + 3
sum(5)(-1)(2) == 6;
sum(6)(-1)(-2)(-3) == 0;
sum(0)(1)(2)(3)(4)(5) == 15;
// Вызовите функцию test, передав такую функцию, чтобы в результате в консоли приложения было выведено
// test 1
// test 2
// test 3
function test(fn) {
fn();
setTimeout(() => console.log("test 3"), 0);
console.log("test 1");
}
// Напишите полифил для функции Promise.allSettled()
const promise1 = Promise.resolve(3);
const promise2 = new Promise((resolve, reject) => setTimeout(reject, 100, "foo"));
const promises = [promise1, promise2];
Promise.allSettled(promises).then((results) => console.log(results));
// [{"status":"fulfilled","value":3},{"status":"rejected","reason":"foo"}]
// Написать функцию, которая проверяет, является ли переданная строка палиндромом
// "A man, a plan, a canal: Panama"
// Output: true
// Input: "race a car"
// Output: false
const isPalindrome = function(s) {
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment