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?
Asked
Active
Viewed 64 times
-4
-
You can access those fields directly with `a['fieldname']`. – Octopus Sep 25 '18 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? – tgreen Sep 25 '18 at 21:13
-
Get all the Latitude and Longitude values and verify if it's valid or not. – Analise Sep 26 '18 at 13:27
1 Answers
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