0 votes

I have a survey with programmatically generated questions, and I want to display nicely formatted numbers to participants. Do you know of a way to do this?

Here's an example

Desired output

Tom gave Jerry $500
Tom gave Jerry $100
Tom gave Jerry $50,000
Tom gave Jerry $10,000

Current output

Tom gave Jerry $500
Tom gave Jerry $100
Tom gave Jerry $50000
Tom gave Jerry $10000

Current input

>> numbers = [1000, 100000]
>> ratios = [0.5, 0.1]
>> questions = []

*for: n in numbers
	*for: r in ratios
		>> questions.add([n*r])

*for: q in questions
	Tom gave Jerry *${q}*

Thank you!

So far, I have tried using the .text method, and also tried generating a collection object that iterates through the text of the number, adding commas (but then I can't convert it back to a string)

by (230 points)
edited by

1 Answer

0 votes

I managed to build a not-great workaround, but the best approach might be embedded javascript or pre-generating the conditions outside of GT.

Here's the workaround, relying on two programs (one that takes variables a and b as input and returns num and exp, and a second that takes num and exp as input, returning currency).

multiply_num_with_ratio: https://www.guidedtrack.com/programs/22840
convert_to_currency: https://www.guidedtrack.com/programs/22841

>> numbers = [1000, 10000]
>> ratios = [0.1, 0.5] 
>> numbers = {}
>> questions = []
*for: n in numbers
	*for: r in ratios
		>> a = n
		>> b = r
		*program: multiply_num_with_ratio
		*program: convert_to_currency
		>> questions.add(currency)
*for: q in questions:
		Tom gave Jerry *{q}*
by (230 points)
Welcome to Guidedtrack Q&A, where you can ask questions and receive answers from other members of the community.
134 questions
144 answers
55 comments
40 users