Reputation: 77
So I wanted to have 2 text field where users choose which symbol to use in creating their triangle.
So the user input a size, let's say 4, then chooses #
as first row and input any symbol as the second row, it will look something like this:
#
gg
###
gggg
I've done it with only 1 pre-set symbol for all the row to be as:
#
##
###
####
I just don't know how to set it so user chooses which one to be presented, any help? Here's my code http://jsfiddle.net/u6mjm/2/
Upvotes: 0
Views: 430
Reputation: 191729
You're missing the acquisition of the second value:
var secondChoice = customJS.get("secondChoice").value;
You can also change createLine
to accept a second argument that is the symbol to print. To determine which symbol, just check whether i % 2
is truthy:
var oneLine = createLine ( i, i % 2 ? firstChoice : secondChoice );
http://jsfiddle.net/ExplosionPIlls/u6mjm/3/
Upvotes: 1