As you can see person2 has multiple nicknames. His nickname returns as Harry, Ralph. I want to be able to check for these individually. Is there a way to determine length of the nickname property so I can run through a for loop. Or a way to push each individual nickname to another array and get length that way. What’s the code to access the nickname separately so I can compare if a person3 for instance shares a similar nickname. Thanks.
You should just be able to ask for .nickname.length on whatever object (e.g. $char.stats[_stats[_i]].nickname.length).
But if it’s a string that will give you the length of the string, so…you’ll probably first want to check if typeof obj.nickname === 'string'. Or store even single nicknames in an array: nickname: ["Robert"].
Ok, so <<print $char.stats[_stats[_i]].nickname.length>> does return the correct number as long as I have brackets [ ] around the nicknames…you were right in that it returned the string length when [ ] weren’t involved.
What I’m really after though is how do I access the 2nd nickname only if someone has a second nickname for instance.
I’ve tried something like <<print $char.stats[_stats[_i]].nickname.>>, but that just errors.