Answer the question
In order to leave comments, you need to log in
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);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question