Мессенджер на чистом JS. Работа с DOM (открой gist чтобы посмотреть разметку, стили и код)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <style> | |
| .container { | |
| padding: 0; | |
| } | |
| .page-width { | |
| margin: 0; | |
| max-width: 100vw; | |
| } | |
| .marquee-container { | |
| overflow: hidden; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Способ номер 1: (единственный минус - считывает пустую строку как 0) | |
| prompt() * 0 !== 0 | |
| ? console.log(`Вы ввели не число`) | |
| : console.log(`Вы ввели число`) | |
| // Способ номер 2: (минусов нет кроме того, что немного длиннее) | |
| const input = prompt(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let getDocumentsNumbers = function(docsArr, year) { | |
| let docs = docsArr.filter(doc => doc.slice(3).includes(year)).length; | |
| return docs; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <link rel="icon" type="image/svg+xml" href="/vite.svg" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
| <title>Vite App</title> | |
| <style> | |
| table { | |
| border-collapse: collapse; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Создайте функцию, которая принимает массив URL и функцию fetch, и запускает все запросы параллельно, | |
| // но с ограниченным количеством одновременных запросов. | |
| // Например, если вы запрашиваете 100 URL, но у вас есть ограничение в 5 одновременных запросов, | |
| // то ваша функция должна гарантировать, что в любой момент времени не будет больше 5 одновременных запросов. | |
| var parallelPromisesWithLimit = async function (promisesArr, parallelLimit) { | |
| const parallelRequests = []; //те, что могут идти параллельно | |
| const allRequests = []; // а тут соберем все завершенные | |
| for (const everyPromise of promisesArr) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getAllKeys(obj, options = {}) { | |
| const { | |
| includeSymbols = false, | |
| excludeBuiltIn = false, | |
| sort = false | |
| } = options | |
| const keys = new Set() | |
| let current = obj |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function map(arr, callback) { | |
| const result = []; | |
| for (let i = 0; i < arr.length; i++) { | |
| result.push(callback(arr[i], i, arr)); | |
| } | |
| return result; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useEffect, useState } from "react" | |
| import styled from 'styled-components' | |
| const API_URL = "https://jsonplaceholder.typicode.com/todos" | |
| interface Todo { | |
| userId: number; | |
| id: number; | |
| title: string; | |
| completed: boolean; |