skip to Main Content

my json is:

export  const wordTrans_ar =  [
        {
            "english_word": "window",
            "hebrew": "חלון",
        },

        {
            "english_word": "good",
            "hebrew": "טוב",
        }
[

i want my function (in react) to return only the 1st item (the english_word) of the 1st sell in my json array.

i traied : a_arr.english_word[0]

but it didn’t work. why?

how do i write it?

2

Answers


  1. you have to access the index of your array first, before you want to get the english_word property.
    In your example, that would be:

    wordTrans_ar[0].english_word

    Login or Signup to reply.
  2. Can you try

    a_arr[0].english_word
    

    You have to trace the object structure when accessing items.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search