I have this:
if (rows[i]["SUB_STATUS"] == "ACTIVE") {
console.log("status is " + rows[i]["SUB_STATUS"])
} else if (rows[i]["SUB_STATUS"] == "INACTIVE") {
console.log("status is inactive " + rows[i]["SUB_STATUS"])
}
and I want to count the number of rows that my table holds with rows[i]["SUB_STATUS"] = to inactive, and active. How is this possible?
Without having more context, I can't tell exactly how you want this information stored. However, it is rather simple to keep a count of occurrences. You can store the number of times you encounter either of these situations in variables.
let numActive = 0;
let numInactive = 0;
if (rows[i]["SUB_STATUS"] == "ACTIVE") {
numActive++;
console.log("status is " + rows[i]["SUB_STATUS"])
} else if (rows[i]["SUB_STATUS"] == "INACTIVE") {
numInactive++;
console.log("status is inactive " + rows[i]["SUB_STATUS"])
}
// Do something with these values
console.log('Number of active:', numActive);
console.log('Number of inactive:', numInactive)