Use a consistent, readable JavaScript style that favors early exits, standard APIs, and lint-safe expressions—without sacrificing clarity.
else.Array.isArray(arr) instead of arr instanceof Array.const/let) to prevent accidental globals.Example (guard clause + standard API + clear return):
const last = arr => (Array.isArray(arr) ? arr[arr.length - 1] : undefined);
const goobox = url => {
const dropbox = /(http(s)*:\/\/)*(www\.)*(dropbox.com)/;
const drive = /(http(s)*:\/\/)*(www\.)*(drive.google.com\/file\/d\/)/;
if (url.match(dropbox)) {
return url.replace(/(http(s)*:\/\/)*(www\.)*/, 'https://dl.');
}
if (url.match(drive)) {
const fileId = url.replace(drive, '').match(/[\w]*\//)[0].replace(/\//, '');
return `https://drive.google.com/uc?id=${fileId}`;
}
return null;
};