I
I
Ilya Ivanov2019-11-01 21:00:48
Node.js
Ilya Ivanov, 2019-11-01 21:00:48

The node.js script did according to the guide (top 10 in terms of balance) but something does not work. how to solve?

5dbc7203ec09f822168296.png
the code itself
updates.hear(/(?:Top|top)/i, (context) => {
let _users = [];
for (let key in users) {
if (users[key] .permission === 0 && !users[key] .ban){
_users.push({
id: key,
balance: users[key] .balance,
});
}
}
return context.send(
"Top 10 by balance:\n" +
_users
. sort((a, b) =>b.balance - a.balance)
.slice(0, 10)
.map((x, i) => `${++i}. @id${x. id} - ${x.balance}`)
.join("\n")
);
});

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
McBernar, 2019-11-01
@McBernar

Indeed - something does not work.
But there is a solution - to fix what does not work.
Don't thank.

A
Adel Khalitov, 2019-11-02
@adelkhalitov

First, when starting the node, insert --inspect and open devtools google.
And see what the code will do in each loop. What you propose is not entirely appropriate, especially such a format for submitting code)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question