I am a newbie js "developer" and for practice, I created a tiny (8 methods) JavaScript library. I need you to give me feedback "should I keep expanding my library or switch to something else" and how do I improve the code quality?
full code:
function isObject(val) {
if (val === null) { return false;}
return ( (typeof val === 'function') || (typeof val === 'object') );
}
function isDate(value) {
switch (typeof value) {
case 'number':
return true;
case 'string':
return !isNaN(Date.parse(value));
case 'object':
if (value instanceof Date) {
return !isNaN(value.getTime());
}
default:
return false;
}
}
function isEmptyOrOnlySpacesString(str) {
return (!str || /^\s*$/.test(str));
}
function getTimeZone() {
return Intl.DateTimeFormat().resolvedOptions().timeZone;
}
function doesObjectHaveEmptyProperties(obj) {
let emptyKeys = [];
for(let key in obj) {
if(obj[key] === "") {
emptyKeys.push(key + " is empty.\n");
}
}
return emptyKeys.join('') + ' others keys are filled';
}
function isSorted (arr){
return arr.every((a,b,c) => !b || c[b-1] <= a);
}
function shuffleArray (arr){
let len = arr.length;
while (len) {
const i = Math.floor(Math.random() * len--);
[arr[len], arr[i]] = [arr[i], arr[len]];
}
return arr;
}
function generateRandomIntArr(len, upTo){
return Array.from({ length: len }, () => Math.floor(Math.random() * upTo));
}
Also you can visit my github repo
thanks in advance