Skip to content Skip to sidebar Skip to footer

How To Further Split String In Object For Javascript Please?

I have two object now obj1-> [ 'logo', 'FinTech startup', 'design' ] obj2-> [ 'logo', 'tech startup', 'design' ] What is the fastest way to turn them into obj1-> [ 'logo'

Solution 1:

You could use Array#join and Array#split with space.

var array1 = ['logo', 'FinTech startup', 'design'],
    array2 = ['logo', 'tech startup', 'design'];
    
array1 = array1.join(' ').split(' ');
array2 = array2.join(' ').split(' ');

console.log(array1);
console.log(array2);
.as-console-wrapper { max-height: 100%!important; top: 0; }

Post a Comment for "How To Further Split String In Object For Javascript Please?"