JS followed by text, ok. More JS in passage? No.

Dennis Carlyle
(New to Javascript & Squiffy)

After a lot of tries, I think I'm getting a handle on how to use a JS array in Squiffy. But I wonder if this below is expected behaviour -- where having some JS starting off a passage is fine, but if you follow it with some regular text, then any JS after that text won't work. Or am I just missing something about using Javascript, or arrays?


You put a nice head of [lettuce] in your basket.

[lettuce]:
squiffy.set("food", "nothing");
var foods = ["pasta", "sugar"]
foods.push("lettuce");

squiffy.set("food", foods[2]);

You check off {food} from your grocery list.

squiffy.set("gender", "female");

You chose {gender} as your gender.


Output:

You put a nice head of lettuce in your basket.

You check off lettuce from your grocery list.

squiffy.set("gender", "female");

You chose null as your gender.



So 'pushing' lettuce to add it to the array works. But then, after the "You check off . . . " text, Squiffy doesn't recognize indented text as JS?

leobos67
Alex says that JavaScript code must be written just below the passage title.
I've found the suggestion here: viewtopic.php?f=24&t=6023

Dennis Carlyle
leobos67 wrote:Alex says that JavaScript code must be written just below the passage title.
I've found the suggestion here: viewtopic.php?f=24&t=6023


Thanks.

This topic is now closed. Topics are closed after 180 days of inactivity.

Support

Forums