How can I remove description:("Auto-generated by YouTube.") from title?
[
{
title: 'DÁKITI description:("Auto-generated by YouTube.")',
author: 'Bad Bunny',
duration: 205090
}
]
Thanks in advance!
How can I remove description:("Auto-generated by YouTube.") from title?
[
{
title: 'DÁKITI description:("Auto-generated by YouTube.")',
author: 'Bad Bunny',
duration: 205090
}
]
Thanks in advance!
use map array method, i guess you have other elements in the array with the same substring, then for each one use replace string method:
let data = [
{
title: 'DÁKITI description:("Auto-generated by YouTube.")',
author: 'Bad Bunny',
duration: 205090
}
]
let result = data.map(e => ({...e,title:e.title.replace('description:("Auto-generated by YouTube.")','').trim()}))
console.log(result)
I hope this is usefull for uh .Using the map method and replace value .
const data = [
{
title: 'DÁKITI description:("Auto-generated by YouTube.")',
author: 'Bad Bunny',
duration: 205090
}
];
const replacedata = data.map(m => {
m.title = m.title.replace('description:("Auto-generated by YouTube.")', "").trim();
return m;
})
console.log('data ', replacedata)
If you have an array with multiple objects with the auto generated description you can use forEach and update the title attribute of each element.
forEach will not create a new array like map will do, it will simply update your existing array.
data.forEach(e => {
e.title = e.title.replace('description:("Auto-generated by YouTube.")', '');
})
let data = [{
title: 'DÁKITI description:("Auto-generated by YouTube.")',
author: 'Bad Bunny',
duration: 205090
}]
data.forEach(e => {
e.title = e.title.replace('description:("Auto-generated by YouTube.")', '');
})
console.log(data)