Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

divide first name and last name in javascript

//  Supported in IE 6-11
const fullName = 'Adam Jones';

//  ['Adam', 'Jones']
const splitOnSpace = fullName.split(' ');
console.log(splitOnSpace);

const first = splitOnSpace[0];
const last = splitOnSpace[1];

console.log(first); //  Adam
console.log(last); //  Jones
Source by bobbyhadz.com #
 
PREVIOUS NEXT
Tagged: #divide #javascript
ADD COMMENT
Topic
Name
6+4 =