How do I extract user initials?

eg. User name is Dave Anderson. What would the formula be to return “DA”? I’m not that familiar with weweb text functions.

It would be something like

[your_name_text_variable].split(" ").map(name => name.slice(0,1)).join("")

For things like this, the built in AI assistant is really helpfull :+1::+1:

1 Like

Thanks @Broberto and @thomlov for your suggestions. I’ll try both. Regarding Thomlov’s: I got this reply from CoPilot:

I tried to implement this in weweb formula as follows, and got an error:

I asked CoPilot to fix the error, but no luck. Suggestions for how to make an acceptable formula?

Broberto, is that custom javascript? Also, I have a “name” field… I don’t really understand why I need a variable. I have a weweb collection of chat messages, and I want to display the initials of the author of each chat message.

You don’t need it indeed, the [bracketed value] can be your variable. I just added a variable via let in the console so it would return something.

Hey!

Check this short video for an example of how to use the AI for generating code like this.
You could also use this to generate nocode formulas, but it might be a bit limiting.

TEST | WeWeb - 31 July 2024 - Watch Video

Thanks so much guys - I got the Javascript to work!