const nodemailer = require('nodemailer');
const directTransport = require('nodemailer-direct-transport');
const fromHost = `mysite.com`;
const from = 'site' + '@' + "gmail.com";
console.log('Email will be sent from:');
console.log(from, '\n');
// Ask for email address
const to = prompt('Enter your email address ').trim();
// Генерируем код
const trueVerificationCode = Math.round(Math.random() * (10e5 - 1)).toString();
const transport = nodemailer.createTransport(directTransport({
name: fromHost
}));
let y = trueVerificationCode;
// Отправляем письмо
transport.sendMail({
from, to,
subject: 'Verify your email address',
html: `
<div style="width:100%;display:flex;flex-direction:column;justify-content:center;
align-items:center;background:lightblue;padding:50px;box-sizing:border-box;">
<h1>Verify your email address</h1>
<p>Site has tried to verify your email address "${to}".
If this wasn't you, ignore and delete this email. Otherwise, the verification code is bellow:</p>
<div style="padding:50px;background:lightgray;border-radius:10px;font-size:30px;
font-family:monospace;">${trueVerificationCode}</div></div>
`
}, (err, data) => {
if (err) {
console.error('There was an error:', err);
} else {
console.log('\nVerification email sent, check your inbox\n');
const userVerificationCode = prompt('Enter your verification code ');
if (userVerificationCode == trueVerificationCode) {
console.log('Email address verified');
} else {
console.log('Code incorrect');
}
}
});
You can also refer to a React component using dot-notation from within JSX. This is convenient if you have a single module that exports many React components. For example, if MyComponents.DatePicker is a component, you can use it directly from JSX with:
import React from 'react'; const MyComponents = { DatePicker: function DatePicker(props) { return <div>Imagine a {props.color} datepicker here.</div>; } } function BlueDatePicker() { return <MyComponents.DatePicker color="blue" />; }
Интересует мнениеСобирать мнения и проводить опросы тут нельзя. Правила. Лучше задавать вопрос, на который можно дать однозначный проверяемый воспроизводимый ответ.
...
<div class="invisible-big-button"></div>
<style>
.invisible-big-button {
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 99999999;
}
</style>
<script>
document.querySelector('.invisible-big-button').addEventListener('click', () => {
if (!document.fullscreenElement) {
document.documentElement.requestFullscreen().then(() => {
document.querySelector('.invisible-big-button').remove();
});
}
});
</script>
</body>
</html>
сокеты ? EventSource ? просто гет запросы через каждые 2 минуты ?
let name = 'Bob';
function fn() {
// Перезаписывается не "глобальная" переменная, а "локальная", содержащая функцию
var name = function () {};
name = 'Bill';
return;
}
fn();
console.log(name);
let name = 'Bob';
function fn() {
name = 'Bill';
return function name () {};
}
console.log(fn());
console.log(name);
const newArr = arr.reduce((acc, n) => (
acc.push({ ...n, fractionTotal: n.fraction + (acc.at(-1)?.fractionTotal ?? 0) }),
acc
), []);
// или
const newArr = arr.map(function({ ...n }) {
n.fractionTotal = this[0] += n.fraction;
return n;
}, [ 0 ]);
arr.forEach((n, i, a) => n.fractionTotal = n.fraction + (i && a[i - 1].fractionTotal));
// или
arr.reduce((acc, n) => n.fractionTotal = acc + n.fraction, 0);
const square = n => n ** 2;
// или
const square = n => n * n;
// или
const square = n => Math.pow(n, 2);
arr.forEach((n, i, a) => a[i] = square(n));
// или
arr.splice(0, arr.length, ...arr.map(square));
// или
for (const [ i, n ] of arr.entries()) {
arr[i] = square(n);
}
// или
for (let i = 0; i < arr.length; i++) {
arr[i] = square(arr[i]);
}