How we can return a specific element of an Array from function in JavaScript?

 For outside array



Steps:

Step 1: Define an array. For example, let’s define an array of Number

             

Step 2: Define a function that takes two parameters:  array and the index 


Step 3: In this function, array[index] will return the element at the specified index in the array


Step 4: Call the function with the number(original Array) and the index of the element you want to return


Another Method👇




For inside array





Comments

Popular posts from this blog

How function return an Array in JavaScript