IF condition with array index

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

I’m kind of new to programming and I want to know if there is a way without a for loop to discovery and use the index of an array.

Example:
var clock = [orange, yellow, abc, …, ]

If clock index is 2:
print (“spiderman”)

I dont understand the question. An array is an object with components inside. Each component has an index asociates. You want to see what the ‘current’ index of an array is? Well, You will have to create and modify the index yourself. If you tell me what you want to acomplish, may be i can help you more

p7f | 2018-12-24 21:22

There’s no such thing as “discovering an index of an array”. No offense but it really does sound like you’re a beginner at programming. Read this and this, and come back later.

SIsilicon | 2018-12-24 22:58

:bust_in_silhouette: Reply From: MysteryGM

want to know if there is a way without a for loop to discovery and use the index of an array.

You can program your own data structure, that keeps track of the indexes for you, adding the functionality.

Instead I will recommend using Dictionaries, these have a index that you can just call when you want.