Forum Discussion
XavierToyos
4 months agoCommunity Member
Problems with a javascript
Hello everyone. There are two things happening to me in the same project and I wanted to share it with you in case someone has encountered the same problem and, most import...
KarlManning-f1e
4 months agoCommunity Member
Hi,
You have 3 names on the screenshot, the code is only using 2. Also Moodle is storing them the other way round.
Try this:
var array = myName.split(' ');
firstName = array[0];
lastName = array[1];
With your login lastName = TOYOS
If you want to use the last name from Moodle, allowing for 3 or 4 names, try this instead
lastName = array[array.length - 1];
With your login lastName would be RIERA
Hope that helps!
Karl