Harrison Deng ba566040b1 Rewrite phase 1.
Started improved client code structure.

Implemented session based authentication serverside.

Implemented user, match, and sport database models serverside.

Implemented Controllers for variety of C and R operations of CRUD.
2022-04-04 20:15:43 -05:00

22 lines
455 B
JavaScript

export function grammaticalListString(items, max) {
if (!items) return null;
if (max < 1) return "";
let built = "";
let index = 0;
items.forEach(item => {
if (index > max) {
built += "and " + items.length + " more ";
return;
}
built += item;
built += ", ";
if (index == max - 1) {
built += "and ";
}
index += 1;
});
return built;
}