Passing single value from array

21 views
Skip to first unread message

danprend...@gmail.com

unread,
Jan 26, 2022, 2:37:01 PMJan 26
to Google Apps Script Community
I'm having trouble passing a single value from an array into another function.  The purpose of this call is to pass the entries from the array, one at a time, were a calculation is done using those values.  However, the entire array is being passed.


for (var j = 0; j <= 15; j++) {
course = week_course[j];
score = VP_Scores[j];
handicap = CalcWeeklyHandicap (score,course);
};

In the above, the variables "course" and "score" contain the entire array as opposed to the value only in the "j" entry of the table.

I tried originally passing the week_course[j] and VP_Scoring[j] variables and then tried this iteration but both resulted in the entire array being passed.

How can I pass just the value in the "j" entry of the table.

Thanks

Dan Prendergast

unread,
Jan 26, 2022, 3:53:51 PMJan 26
to google-apps-sc...@googlegroups.com
I think I have this figured out, kind of.  The week_course variable is a 2 dimension array.  I’m not sure why, but this was the problem.  

Thanks

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/87495628-c003-49d8-92be-74879bfe4d2bn%40googlegroups.com.

Robert B Johnson

unread,
Jan 27, 2022, 6:15:10 AMJan 27
to Google Apps Script Community
I had ran into that very same issue,, the way I figured it out was to use "logger.log" this is like "Console.log" in traditional JS  only then did I see that the array I was targeting was wrapped in a second array

"  [ [ 1,2,3,4,5] ]"    

Later
Bob

Reply all
Reply to author
Forward
0 new messages