Find item in array and delete it - Forum

Forum Navigation
You need to log in to create posts and topics.

Find item in array and delete it

Hi there. How can I find index of item in array by user input variable? Then delete it.

Ex:

[{"city":"Tehran"},{"city":"Newyork"},{"city":"London"}]

 

User input Variable: Newyork

@tilesoft take a look at this code and let me know if you have any doubts:

BeginJS
  $App.data = [{"city":"Tehran"},{"city":"Newyork"},{"city":"London"}];
EndJS
SetVar [userInput] "Newyork"

Loop 0 [data.length-1] [n]
   If [data([n]).city] == [userInput]
      ArrayDelItem [data] [n]
   EndIf
EndLoop

Reagrds.