JavaScript Support

andrew-robertson
Community Member Posts: 277 ☆ Superstar ☆
Hello there -
I have a fairly complex simulation that I am building out with the Lectora V21 application. I am stumped at one spot though.
I have a variable called _Lane2SearchDetails that is instantiated by Lectora and I either add or subtract values based on button clicks. There is a finite amount of information that can be assigned to that _Lane2SearchDetails (z1,z2,z3,z4,z5,z6).
Since this variable essentially is an array separated by commas, I would like to split the array using the str.split(',') function built into JavaScript. My best attempt is in a screenshot below.

Now, when I call that function I always get a minimum of one object in the array length, and it only goes up from there or down as a button is unclicked - but it never goes to 0 if there is no objects in the string or ~~~~null~~~~.
The flow occurs as listed below.
Button 1 Clicked (Enabled): Array length = 2, Array contents = z1,
Button 2 Clicked (Enabled): Array length = 3, Array contents = z1,z2,
Button 3 Clicked (Enabled): Array length = 4, Array contents = z1,z2,z3
Button 1 Clicked (Disabled): Array length = 3, Array contents = z2,z3,
Button 2 Clicked (Disabled): Array length = 2, Array contents = z3,
Button 3 Clicked (Disabled): Array length = 1, Array contents = ~~~null~~~
Unsure why it is giving me the array length of current length + 1.
Anything I am doing wrong (obviously I am)?
I have a fairly complex simulation that I am building out with the Lectora V21 application. I am stumped at one spot though.
I have a variable called _Lane2SearchDetails that is instantiated by Lectora and I either add or subtract values based on button clicks. There is a finite amount of information that can be assigned to that _Lane2SearchDetails (z1,z2,z3,z4,z5,z6).
Since this variable essentially is an array separated by commas, I would like to split the array using the str.split(',') function built into JavaScript. My best attempt is in a screenshot below.

Now, when I call that function I always get a minimum of one object in the array length, and it only goes up from there or down as a button is unclicked - but it never goes to 0 if there is no objects in the string or ~~~~null~~~~.
The flow occurs as listed below.
Button 1 Clicked (Enabled): Array length = 2, Array contents = z1,
Button 2 Clicked (Enabled): Array length = 3, Array contents = z1,z2,
Button 3 Clicked (Enabled): Array length = 4, Array contents = z1,z2,z3
Button 1 Clicked (Disabled): Array length = 3, Array contents = z2,z3,
Button 2 Clicked (Disabled): Array length = 2, Array contents = z3,
Button 3 Clicked (Disabled): Array length = 1, Array contents = ~~~null~~~
Unsure why it is giving me the array length of current length + 1.
Anything I am doing wrong (obviously I am)?
Andrew R.
Developing content since 2010 using a mixed bag of tools.
Developing content since 2010 using a mixed bag of tools.
Comments
-
What's wrong with the length?
When you split "z1," by the comma the resulting array should have two items: "z1" and "" (i.e. an empty item). The term "~~~null~~~" is a placeholder for "" (empty) that Lectora puts in. The moment you leave the Lectora context it is regular text, which makes it the first / only item of the array.
You might try to remove the last comma in the value before you turn it into an array:tempLaneZonesSearched = tempLaneZonesSearched.substring(0, tempLaneZonesSearched.length - 1);
This actually removes the last character, but that should usually be a comma in your case.
You can also remove the last item of the array:zoneArray.pop();
-
Categories
- 4.8K All Categories
- 6 New Feature Releases
- The Training Arcade®
- Arcades™
- 125 ✫ Announcements
- 9 ✪ Contests
- 34.1K eLearning Brothers® Products
- 33.6K Lectora®
- 31.6K Lectora Discussions
- 1.9K Lectora Feature Requests
- 71 Lectora User Groups
- 17 Asset Library
- 10 AssetLibrary Discussions
- 7 AssetLibrary Feature Requests
- 304 CenarioVR®
- 178 CenarioVR Discussions
- 126 CenarioVR Feature Requests
- 40 Rockstar Learning Platform®
- 28 Rockstar Learning Platform Discussions
- 12 Rockstar Learning Platform Feature Requests
- 4 Off-the-Shelf Course Library
- 3 Off-the-Shelf Course Library Discussions
- 1 Off-the-Shelf Course Library Feature Requests
- 114 CourseMill®
- 107 CourseMill Discussions
- 44 ReviewLink®
- 32 ReviewLink Discussions
- 12 ReviewLink Suggestions
- 2 The Training Arcade®
- 1 The Training Arcade Discussions
- 1 The Training Arcade Feature Requests
- 10 Additional Learning Products
- 2 Adobe®
- 4 Articulate®
- 2 Camtasia®
- Docebo®
- 1 iSpring®
- 1 Microsoft® PowerPoint®
- 932 All Things eLearning
- 5 Course Development Showcase
- 1 eLearning Brothers® Downloads
- 1 Compliance Training
- 11 eLearning Development
- eLearning Game Design
- 7 Instructional Design
- 545 Learning Management System (LMS) Integration
- 3 Mobile Learning
- 22 Visual Design
- 331 Web Accessibility
- 1.2K ♪ The Green Room
- 8 ♡ Community Feedback
- 7 Community Tips