function isNegativeInteger(s) {
if (typeof s !== 'string') {
return false;
}
const n = Number(s);
if (Number.isInteger(n) && n < 0) {
return true;
}
return false;
}
console.log(isNegativeInteger('0'));
console.log(isNegativeInteger('2'));
console.log(isNegativeInteger('-9'));
console.log(isNegativeInteger('-3.14'));
console.log(isNegativeInteger(''));
console.log(isNegativeInteger('node.js'));
console.log(isNegativeInteger(' '));
/*
run:
false
false
true
false
false
false
false
*/