const login = 'Login2';
const data = [
{
"id": "1",
"login": "Login1",
},
{
"id": "2",
"login": "Login2",
}
];
const loginFound = !!data.find(l => l.login === login);
console.log(loginFound);
const createSequence = numbers => {
const store = numbers.reduce((accumulator, number) => {
accumulator.intermediateValue += number;
accumulator.sequence.push(accumulator.intermediateValue);
return accumulator;
}, {
sequence: [],
intermediateValue: 0
});
return store.sequence;
};
const newArr = arr.reduce((acc, n, i) => (acc.push(n + (acc[i - 1] ?? 0)), acc), []);
// или
const newArr = arr.reduce((acc, n) => (acc[0].push(acc[1] += n), acc), [ [], 0 ])[0];
// или
const newArr = arr.map((n, i, a) => eval(a.slice(0, i + 1).join('+')));
// или
const newArr = arr.map((n, i, a) => a.reduce((acc, m, j) => acc + m * (j <= i), 0));
arr.forEach((n, i, a) => a[i] += a[i - 1] ?? 0);