let logMessage = type
.replace('[playerKick]', name1)
.replace('[playerDefence]', name2);
export const generateLogs = (type, player1, player2, damage = 0) => {
const { name: name1 } = player1;
const { name: name2 } = player2;
const logMessage = type
.replace('[playerKick]', name1)
.replace('[playerDefence]', name2);
switch (type) {
case 'start':
return logMessage + LOGS.start
.replace('[time]', getTime())
.replace('[player1]', name1)
.replace('[player2]', name2);
case 'hit':
return logMessage + `${LOGS.hit[getRandom(0, LOGS.hit.length - 1)]
.replace('[playerKick]', name1)
.replace('[playerDefence]', name2)} -${damage}
[${player2.hp} / 100]
`;
case 'defence':
return logMessage + LOGS.defence[getRandom(0, LOGS.defence.length - 1)]
.replace('[playerKick]', name2)
.replace('[playerDefence]', name1);
case 'end':
return logMessage + LOGS.end[getRandom(0, LOGS.end.length - 1)]
.replace('[playerWins]', name1)
.replace('[playerLose]', name2);
case 'draw':
return logMessage + LOGS.draw;
default:
return logMessage + '...';
}
};
export const insertLogs = (logMessage) => {
const el = `<p>${logMessage}</p>`;
chat.insertAdjacentHTML('afterbegin', el);
};
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<div class="cards">
<div class="card">
<h1>Далеко-далеко за словесными горами.</h1>
<span
>Далеко-далеко за словесными горами в стране гласных и согласных живут
рыбные тексты.</span
>
</div>
</div>
<style>
body {
color: #fff;
background: #00010e;
display: flex;
justify-content: center;
}
* {
margin: 0;
padding: 0;
}
.cards {
overflow: hidden;
display: flex;
flex-direction: column;
min-height: 100vh;
justify-content: center;
}
.card {
display: flex;
flex-direction: column;
gap: 50px;
padding: 70px;
border: 2px solid rgb(65, 66, 50);
position: relative;
}
.card h1,
.card span {
z-index: 1;
}
.card::after,
.card::before {
display: block;
content: "";
width: 45%;
aspect-ratio: 1/1;
border-radius: 20% 100% 20%;
transform: rotate(-20deg);
position: absolute;
background: #00010e;
box-shadow: 0 15px 50px 30px #00010e;
animation: 10s rotate infinite alternate;
}
@keyframes rotate {
from {
transform: rotate(-20deg);
}
to {
transform: rotate(360deg);
}
}
.card::after {
right: 0;
top: -65%;
right: -10%;
}
.card::before {
width: 30%;
bottom: -50%;
left: 20%;
}
</style>
</body>
</html>
const getShuffledArray = (min, max) => {
const randoms = Array(max - min + 1).fill(min).map((n, i) => n + i);
for (let i = randoms.length - 1; i > 0; i -= 1) {
const r = Math.floor(Math.random() * (i + 1));
[randoms[i], randoms[r]] = [randoms[r], randoms[i]];
}
return randoms;
}
getShuffledArray(5, 10);
// [ 6, 10, 7, 5, 8, 9 ]
getShuffledArray(5, 10);
// [ 9, 6, 5, 7, 8, 10 ]
function orderedCount2(str) {
const symbols = new Map();
for (const c of str) {
const currCount = symbols.get(c) || 0;
symbols.set(c, currCount + 1);
}
const totalCount = str.length;
const orderedSymbols = {};
for (const [symbol, count] of symbols.entries()) {
orderedSymbols[symbol] = (count / totalCount) * 100;
}
return orderedSymbols;
}
input:
orderedCount("hello world")
output
{
h: 9.090909090909092,
e: 9.090909090909092,
l: 27.27272727272727,
o: 18.181818181818183,
' ': 9.090909090909092,
w: 9.090909090909092,
r: 9.090909090909092,
d: 9.090909090909092
}
мини пет проекты есть, по типу формы авторизации, лендосов, чат бот и т.д
export default {
build: {
outDir: 'dist', // имя общей выходной директории
assetsDir: 'js' // имя директории со статикой
//assetsDir: './' // размещение статики внутри "dist"
}
}
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist/js'),
//path: path.resolve(__dirname, 'dist'), // размещение статики внутри "dist"
filename: 'bundle.js'
}
};