Budibase is an open-source low-code platform for creating internal apps in minutes. Supports PostgreSQL, MySQL, MSSQL, MongoDB, Rest API, Docker, K8s 🚀
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

28 lines
559 B

/**
* Join `arr` with the trailing `str` defaulting to "and",
* and `sep` string defaulting to ", ".
*
* @param {Array} arr
* @param {String} str
* @param {String} sep
* @return {String}
* @api public
*/
module.exports = function(arr, str, sep){
str = str || 'and';
sep = sep || ', ';
if (arr.length < 2) return arr[0] || '';
var oxford = str.slice(0, 2) === sep;
if (!oxford) {
str = ' ' + str;
} else if (arr.length == 2) {
str = str.slice(1);
}
return arr.slice(0, -1).join(sep) + str + ' ' + arr[arr.length - 1];
};