My boss now wants me to implement a mechanism that lets him search for an item in an array, and gives him the index/indices where that value occurs.
Your Task:
Write a program or function that receives an array and a value (String, Integer, Float, or Boolean), and returns the indices of the array at which the value occurs (either 0 or 1 indexed, whichever you prefer). If the value is not in the array return an empty array.
Input:
An array A and a value V, that may or may not be present in A.
Output:
An array containing the indice(s) at which the V occurs in A, or, if V does not occur in A, an empty array.
Test Cases:
Please note that the test cases are 0 based.
12, [12,14,14,2,"Hello World!",3,12,12] -> [0,6,7]
"Hello World", ["Hi", "Hi World!", 12,2,3,True] -> []
"a", ["A",True,False,"aa","a"] -> [4]
12, [12,"12",12] -> [0,2]
Scoring:
This is code-golf, so the lowest score in bytes wins.