B
B
Blaze6662021-01-27 15:31:40
Node.js
Blaze666, 2021-01-27 15:31:40

How to remove an array element, it is also a user-entered expense?

Hello. I am writing my telegram bot to track financial expenses and I have a question.
First, I will explain the essence of the bot. The task is simple, accounting for financial expenses, adding elements in the format: [amount] [expense] and deleting. Suppose I made a mistake and entered the expense incorrectly, or entered the wrong amount. So that's how I can remove the index of an element that I don't know in advance! I've been sitting on it for a long time, thinking about it.
I will be grateful for any help.
ATP

UPD I found a solution.

const newArr=arr.findIndex(item=>item.amount===formEx[1]);
      arr.splice(newArr,1);


formEx is an array that contains the message from the user. amount-key, in an array of objects.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WbICHA, 2021-01-27
@WblCHA

https://developer.mozilla.org/en/docs/Web/JavaScript...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question