Split First name and Last name using javascript

后端 未结 20 3170
悲&欢浪女
悲&欢浪女 2020-12-08 06:39

I have a user with a name Paul Steve Panakkal. It\'s a long name it won\'t fit to the div container. So is there anyway to split first name and lastname fro

20条回答
  •  隐瞒了意图╮
    2020-12-08 06:44

    const fullName = 'Paul Steve Panakkal'.split(' ');
    const lastName = fullName.pop(); // 'Panakkal'
    const firstName = fullName.join(' '); // 'Paul Steve'
    console.log(firstName);
    console.log(lastName);

提交回复
热议问题