How to skip array index into first specific number?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By DeerForMera

Let’s say I have an array like [0, 1, 0]. I want to add 1 into first 0,
so it will be [1, 1, 0]. Then if I add again it will be [1, 1, 1]. How to code this?

:bust_in_silhouette: Reply From: Inces
var arr = [0,1,0]
var specnumber = 0
for x in range(arr.size()):
      if arr[x] == specnumber:
            arr[x] +=1
            return

Thanks. Its worked

DeerForMera | 2021-12-26 11:56