-4

Please bear with me, I am new to coding. I am trying to test a web service and I am stuck with a java script array where I need to get 2 fields out of 10 fields for further testing. I would really appreciate if someone can help me with it?

3
  • You can access those fields directly with a['fieldname']. Commented Sep 25, 2018 at 21:12
  • hey, could you give a little more info about what you are trying to do? Which fields do you want to get? Any two? Two specific ones? Commented Sep 25, 2018 at 21:13
  • Get all the Latitude and Longitude values and verify if it's valid or not. Commented Sep 26, 2018 at 13:27

1 Answer 1

0

Try this!

<script>
        let colors = ["Red", "Green", "Blue"];
        alert(colors[2]);
</script>

or more generic:

<script>
    let colors = ["Red", "Green", "Blue"];

    //Output: Blue (Note that arrays starts with 0)
    PrintArrayValue(colors, 2);

    function PrintArrayValue(array, index){
        alert(array[index]);
    }
</script>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.