Two variables

+1 vote
asked Aug 10 by Username (300 points)
<<set $a = 1>> //not "1"//
<<set $b = 2>> //not "2"//

<<set $c = //What code should I write here?//>>

<<if $c == 3>>
   No no no...
<<elseif $c == "12">>
   No no no...
<<elseif $c == 12>>
   Yeah!
<</if>>

Or need pure JavaScript?

1 Answer

+1 vote
answered Aug 10 by Chapel (33,780 points)
selected Aug 10 by Username
 
Best answer
This isn't enough to go on. What are you trying to do?
commented Aug 10 by Username (300 points)
edited Aug 10 by Username

Compare two variables.

I need to combine two different variables

$a = 1
$b = 2

I need $a + $b not 3 but 12

 

commented Aug 10 by Chapel (33,780 points)

Maybe try something like this: 

<<set $a to 1>>
<<set $b to 2>>
<<set $c to "" + $a + $b>>
<<set $c to parseInt($c, 10)>>
<<if $c is 12>>true<</if>>

 

commented Aug 10 by Username (300 points)
It works! Many thanks!
Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.
...