-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?

1 Answers1

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>
Peter
  • 314
  • 1
  • 11