Forum Discussion
lmsAPI Functionality in HTML5 Output
Hi Joseph - Good call on this. The only thing you will want to be careful of/double-check, is how it will behave if someone does have a middle name/initial in there. You should be safe if you change the last line to this:
player.SetVar("strLastName",nameArray[nameArray-1]);
This will make it pull the LAST item of the nameArray, no matter how long the array is.
That goes back to the rules your organization has in place for data, in this case, the user name. If the rule is a middle initial is required, it has to be across the board. It can't be there occasionally and absent occasionally. In many organizations, there's some integration going on in the LMS with the people system or mail system (Microsoft Exchange, for example) which enforces business rules for userName and other data points.
Otherwise, it ends up being Garbage in => Garbage Out.